List box populating table from form Results


I have a form with various list boxes that display options based on a query. When options are selected the text relating to them is populated in a seperate text box at the side.

The problem im having is when I select options from the list box I want it to store the selected options in the table that holds each record when the form has been filled out and submitted. At the minute it populates everything into the table apart from the options selected from the list boxes.

Does anyone know how to do this?

Thanks in advance

Edit: I have got the control souurce of the list boxes set to the correct field in the table.

Following on from that thread, I would really like to tidy up other areas of my front end. I am using the idea that Roy suggested and it works very well.

At the moment, I have a form, that has buttons on it that people click when they want to generate specific sheets from excel using data from access using VBA on the form. These work fine, however, now that the database is going live and all features need to be added, I think it would be nice to have one small form, with a list box.

I have converted a copy of the code on the form and placed in a module by declaring then functions instead of private subs.

At this stage, I tried doing it with macros running the code by using a series of runcode. I then created a table that has the macro name stored in it along with a decriptive bit of text detailing the excel chart that gets produced to make it easy for the user.

The list box populates itself correctly, but the problem I am having is I do not know how to make the 'go' button look at the list box, pull the hidden macro/function name from the list, then go and run the macro/function.

I have tried looking about, but have not found anyhthing.

hi Guys

I have a request from a customer to create an form to view images in a table. The idea is this....

a really quick scanner scans 100's of images to a folder. But because they're all different, we dont want to use expensive OCR's the thing:

I can view the images if I import their location (from a CSV file) but I wanna be able to view them directly out of their folder. So the user scrolls through each image, renames the filename and then moves the image to another folder....

The part that confuses me is this:

How do you populate a list box with a list of files in a folder? And then, how do you move the images????

Sorry to lay this on ya's but its driving me mad right now. I've never worked with the DIR() functionality


I have an unbound multi-selection List box on a main form (data entry) which is populated by a query and only becomes visible once the user selects the "Case_ID" from a combo box. I then allow the user to select multiple items in the list to associate with this new record. These associations however are recorded in a seperate link table, hence this list box being unbound.

I can fill out all the fields on the main form including selecting multiple items in the list box, but as soon as I enter the subform the record saves and the selections in the list box disappear. Unfortunately I want to run further code (a dynamically built sql insert statement) on the list box selections once the user hits the 'save' button on the main form (after filling out the subform).

The key for the new record on the main form is an auto-number and so is not assigned until at least one field is populated. As this key is also a foreign key in my link table I cannot save the list box selections until after the main form record is saved.

So basically I am asking how I can maintain the list box selections after the user focuses on a field in the subform? If this is not easily acheived (without a huge block of code) then is there another event on the main form or subform I can use to trigger the list box operations after the main record is saved but before the selections disappear?

I apologise if this is at all unclear, please feel free to ask me further questions.


I thought I had good solution but it's not so good after all..
I have a main form that the allows users to select a Purchase Order Number from a drop down list box. That PO Number selection will pop up another form that displays all the line items from that PO.
The line items of that PO are displayed in a list box. The user selects a line item and the line item information populates fields on the main form.
This was way cool until I noticed that if the user selects/highlights the second item from the list box - it's still populating the main form with the values of the first record.

The list box on the second form is unbound...and it's source is a query of which 6 values are displayed- bound to column 1.
Currently in the double click event of the list box I had following code which successfully inserted values into a table that is used by my main form.

Private Sub LineItems_DblClick(Cancel As Integer)
Dim strSQL As String
Dim item As String
Dim PO As String
Dim PartNum As String
Dim Nomen As String
Dim DwgNum As String
Dim Qty As Integer
Dim Due As Date
Dim key As Integer

PO = Me.PONumber
PartNum = Me.PartNumber
DwgNum = Me.DrawingNumber
Nomen = Me.Nomenclature
Qty = Me.Quantity
Due = Me.DueDate

'strSQL = "UPDATE tblINCOMING_INSPECT_LOG SET PONum = '" & PO & "', PartNumber = '" & PartNum & "', Nomenclature = '" & Nomen & "', DrawingNumber = '" & DwgNum & "', QtyOrdered = " & Qty & ", DateShpDue = # " & Due & " # WHERE IncmgInspectLogID = " & updKey & " ;"
'CurrentDb.Execute strSQL, dbFailOnError
End Sub

Am I not getting the value correctly by doing an assignment like PO = Me.PONumber?

I've 2 queries that I need help on...
Firstly, I'm trying to populate a list box (AuditLog) on a form called F_Devices for table T_Devices with the contents of another table (T_AuditLog) in the same database.

Secondly, I have a number of combo boxes that are populated from tables, all in the same form (F_Devices) - one of the tables (T_ServerType) contains 3 columns, Type, Processor and Memory and depending on what type is selected, then I'd like to automatically populate the Memory and Processor combo boxes with the related values...

Apologies if these are very basic queries but I'm very new to Access...


I am still getting my feet wet in access. I have a continuous form where the user selects values from several bounded combo boxes to update information in Table A consisting of 27 existing records. The row source for the combo boxes are Table 1. The resulting values in the combo box are bounded to Table A to populate the fields. An additional field is populated into a bounded list box through a table query on Table 1 using the combo box values. The resulting list box value should populates the list box for 27 records when it should only be modifying one.

Is there anyway I can limit the update to one list box and prevent the 27 list boxes from being updated when the contents of the combo boxes are modified?

Hey guys. I need some help. I want to create a form with a list box populated with records from a query. I select "Create form in Design Mode," then I drag a listbox onto the form and choose the option "I want the list box to look up the values in a table or query." Then I select the query and select the fields I want to see, hit next and get the message "Data cannot be retrieved from the source you have selected. You must select a different table or query to continue in the wizard." Apparently this is a known issue with microsoft and they have released a fix for it, but that doesnt seem to do anything. My querys are fine, , my tables are fine, , my relationships are good....

So, how can I populate my list box from my query? Im sure there are other ways than using the wizards.


I've looked at many of the posts that already address this issue... but am still struggling.

I created a form (AddrChg) with New address information (stored in AddrChg table). On the form, the user will be required to select a county (County table) from a list box (County table - has three columns: county number, county name, fax number). I created another field (text box?) on the form that I would like to have auto-populate with the Counties' fax number ( mentioned, stored on the County table). So, if a user selected Polk county, the corresponding fax number for that row will autmoatically display in the "Fax Number" test box. The data entered in this form will be written to the AddrChg table.

I've tried a few of the things that were on other posts but I am obvioulsy too new at doing this to get it right cuz I have yet to be successful. I don't believe what I need is a cascading combo box. I fthese two foelds need to be bound, how? Do I need to add an event? If so, to which box (field) and what's the event? If I need to add code PLEASE be very specific - I am NOT a VB programmer (so I would need an explanatin on what it is I am adding and to where and how, etc etc etc). If there is something else I need to do, please keep explanation as simple as possible...


I have set up a form where the user is to select an option from a list box. The table from which the list box gets its records has three coloums, and I need to have data from the other two coloums populate fields automatically within my form.

How do I do this?

Greetings all. I don't know if that subject got your attention or just confused you but I will explain what I am looking for.

I am looking to have either a combo box / text box accept input from the user, eg user puts in first name or last name or SIN or home phone, and when doing so, will bring up any student record with matching criteria, by either *last name, first name, home phone, SIN etc*. And then when the list box has been filtered to what i'm looking for, i want to be able to click that record and open it up.

So here's where I need help. I have NO clue how to do this, I have searched for hours trying to figure this out, downloaded many different options or choices to try them, but I'm just learning Access, so far self taught over these last 3 months, and i'm starting to get stuck on doing things. I am creating a database and I need help with Access. So below is an EG of what i'm looking for.

combobox/textbox,,, user types in last name of McCloud, list box starts populating ANY record that has McCloud in it from a table I have created called *Students*, once I find the record i'm looking for whether theres 1 or 2 or 3+ records, I want to double click on that record in the List Box, and bring that students record up in the form that I have created for Students.

Any helps appreciated , i'm so lost its not funny.

I am a VBA novice and am trying to create a simple household inventory application for personal use. I have categorized household items into Appliances, Furniture, Housewares and so on. A table called tblItemInfo includes the fields Category, Item, Location, Cost, TaxRate, and DeliveryCost. My form contains an unbound text box called txtTotal with the expression =Sum([Cost]+([Cost]*[TaxRate])+[DeliveryCost]) as its control source which calculates the total value for all records. My form also contains a list box named lstSelectItem which displays item names. I populate this list box by selecting a category name from a combo box called cboSelectCategory. For example, when I select "Furniture" in the combo box the list box RowSource is set to display only items in the category of Furniture. I accomplish this by placing the following code in cboSelectCategory AfterUpdate event: lstSelectItem.RowSource = "SELECT AutoNumber, Item, Category FROM tblItemInfo WHERE (((Category) = ' " & cboSelectCategory.Value & " '))". This all works exactly as desired but when I select a category in cboSelectCategory I want txtTotal to calculate the total value for items only in the selected category and I can't figure out how to write the code that will do this. Any help would be greatly appreciated.

I'm working on a database that should update its data from other databases (access 2007). The update command code looks something like this:

Private Sub Update_Button_Click()
On Error GoTo Err_Update_Button_Click
Dim msg As String
Dim resp As String
Dim path As String

msg = "This will first remove, and then update ALL information for " & [District] & " District from the " & [District] & " District Database. Are you sure you want to do this?"
resp = MsgBox(msg, vbYesNo + vbQuestion)
If resp vbNo Then

path = FindDatabase([District])

If Nz(path) "" Then

DoCmd.OpenForm ("Update Database Progress")
Forms![Update Database Progress]![District] = [District]
Forms![Update Database Progress].Repaint

On Error Resume Next

DoCmd.DeleteObject acTable, "Imported Ward List"
DoCmd.DeleteObject acTable, "Imported Village List"
DoCmd.DeleteObject acTable, "Imported Infrastructure"
DoCmd.DeleteObject acTable, "Imported Population District"
DoCmd.DeleteObject acTable, "Imported Travel Times"
On Error GoTo Err_Update_Button_Click

DoCmd.TransferDatabase acImport, "Microsoft Access", _
path, acTable, "Ward List", _
"Imported Ward List"

DoCmd.TransferDatabase acImport, "Microsoft Access", _
path, acTable, "Village List", _
"Imported Village List"

DoCmd.TransferDatabase acImport, "Microsoft Access", _
path, acTable, "Infrastructure", _
"Imported Infrastructure"

DoCmd.TransferDatabase acImport, "Microsoft Access", _
path, acTable, "Population District", _
"Imported Population District"

DoCmd.TransferDatabase acImport, "Microsoft Access", _
path, acTable, "Travel Times", _
"Imported Travel Times"

Forms![Update Database Progress]![Import].Visible = True
Forms![Update Database Progress].Repaint
' Set the Warnings off
DoCmd.SetWarnings False

DoCmd.RunSQL ("DELETE [Ward List].LLG FROM [Ward List] WHERE ((([Ward List].LLG) In (SELECT DISTINCT [Imported Ward List].LLG FROM [Imported Ward List]));")

DoCmd.RunSQL ("INSERT INTO [Ward List] ( LLG, [Ward Number], [Ward Name], Councillor, Notes ) SELECT [Imported Ward List].LLG, [Imported Ward List].[Ward Number], [Imported Ward List].[Ward Name], [Imported Ward List].Councillor, [Imported Ward List].Notes FROM [Imported Ward List];")

Forms![Update Database Progress]![Ward].Visible = True
Forms![Update Database Progress].Repaint

DoCmd.RunSQL ("DELETE [Village List].[LLG Name] FROM [Village List] WHERE ((([Village List].[LLG Name]) In (SELECT DISTINCT [Imported Ward List].LLG FROM [Imported Ward List]));")

DoCmd.RunSQL ("INSERT INTO [Village List] SELECT [Imported Village List].* FROM [Imported Village List];")

Forms![Update Database Progress]![Village].Visible = True
Forms![Update Database Progress].Repaint

DoCmd.RunSQL ("DELETE [Infrastructure].LLG FROM [Infrastructure] WHERE ([Infrastructure].[District] = Forms![Update Database]![District]);")

DoCmd.RunSQL ("INSERT INTO [Infrastructure] SELECT [Imported Infrastructure].* FROM [Imported Infrastructure];")

Forms![Update Database Progress]![Infrastructure].Visible = True
Forms![Update Database Progress].Repaint

DoCmd.RunSQL ("DELETE [Population District].[District] FROM [Population District] WHERE ([Population District].[District] = Forms![Update Database]![District]);")

DoCmd.RunSQL ("INSERT INTO [Population District] SELECT [Imported Population District].* FROM [Imported Population District];")

Forms![Update Database Progress]![Population].Visible = True
Forms![Update Database Progress].Repaint

DoCmd.RunSQL ("DELETE [Travel Times].LLG FROM [Travel Times] WHERE ([Travel Times].District = Forms![Update Database]![District]);")

DoCmd.RunSQL ("INSERT INTO [Travel Times] SELECT [Imported Travel Times].* FROM [Imported Travel Times];")

Forms![Update Database Progress]![Accessibility].Visible = True
Forms![Update Database Progress].Repaint

DoCmd.DeleteObject acTable, "Imported Ward List"
DoCmd.DeleteObject acTable, "Imported Village List"
DoCmd.DeleteObject acTable, "Imported Infrastructure"
DoCmd.DeleteObject acTable,
DoCmd.DeleteObject acTable, "Imported TravelTimes"

Forms![Update Database Progress]![Delete].Visible = True
Forms![Update Database Progress].Repaint
' Set the Warnings back on
DoCmd.SetWarnings True

[Last Updated] = Date

DoCmd.Close acForm, "Update Database Progress"

resp = MsgBox([District] & " District Information successfully refreshed from District Database. The database will now be compressed.", vbInformation)

SendKeys "%TDC"
End If
End If

Exit Sub
If Err.Number = 3024 Then resp = MsgBox("Error 3024 - cannot find the " & [District] & " Database you specified.", vbExclamation)
MsgBox Err.Description
End If
Resume Exit_Update_Button_Click

End Sub
when I clicked the update button, the message box came up asking me if I was wanted to update the database. but when I clicked on "Yes", nothing happened. The window opening the path to which the database gets its update did not come up.

can someone help me?

thanks in advance

I've got a list box on my form that is populated from data located in one of my tables. I would like to be able to add an additional item to this list box for the user to choose from whenever the form is first loaded.

This should be simple, but I am not very familiar with VBA. Can someone help?


A word is chosen in a list box. Actually, there are 7 list boxes or so on the form. I need each word to appear in a text box on the same form.

When the 7 choices are made, could the seven words populate one field of MyTable, in code, please?

I have a DB for requesting Details of Products. My sales coordinator enters the Job information on a form linked to a Request table and enters the parts needed in a subform linked to a Detail Table. I'm using code to create an email populated with data from the Job Info form and want to also include the list of details they have requested from the Detail subform.

I tried using a list box to get the values from the subform up to the form but I could not get the list to print in the email.

I may be going at this the long way so if anyone can help me streamline this, great! Or if you can connect the two points of getting the subform list into my email that would be awesome!

Here is the code I'm using:

'Email Notice

Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurrFile As String

Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

With olMail
.To = "Cavscout"
.Subject = SalesCoord & " entered a Detail Requisition."
.Body = SalesCoord & " has requested a detail('s) for " & vbCr & vbCr & Agent & "," & vbCr & vbCr & _
" for the following systems:" & vbCr & vbCr & ProductsList
End With

Set olMail = Nothing
Set olApp = Nothing

Please let me know if I have been unclear about anything.

Thanks in advance.

Hi all

I've struggled over two days and various newsgroups to find a solution to this problem. Hope some here can help

I have an Access database which is multi-user. Table("A") contains a list of items which can be chosen by any user. Query("B") shows list of items from table which remain un-chosen.

A form contains a "choose" button, a listbox("items available") which is populated by Query "B" an action button which populates the users name into the appropriate field of the table for the item chosen by the user, a cancel button.

Listbox "items available" has visible value set to false until user clicks "choose" button. Cancel button returns the listbox visible value to false after it is clicked.

The form has an "on timer" event which requeries the listbox every 5 seconds. This is to ensure that when two users have the listbox visible on two separate PC's the second user will see the available items being refreshed if first user makes and completes a choice.

The problem starts when a user clicks "choose", makes the list box visible, selects an item in the list box and then, having decided not to complete the choice, they click the cancel button. In the event that the user clicks the "choose" button again the list box becomes visible and still ahs the earlier selection chosen.

I overcame this by incorporating the following code into the "choose" button

Dim i As Integer

For i = 0 To lstavailable.ListCount - 1
Me!lstAvailable.Selected(i) = False

Fine ..... it seemed to work, until the "on timer" event requeried the list box and displayed it with the earlier selection re-selected

Anyone any ideas why this is happening or a solution. The solution must not invlove de-selecting after the requery. In that case since it requeries every 5 seconds users only have that amount of time to complete a choice.

Appreciate any help


Michael Bond

I have 4 option buttons listing 4 different companys. When one is chosen it populates a list box with all employees at that company and when an employee is checked the form is populated with his/her contact info for editing.

What I'd like to do is have an additional list box. When company is checked this list box is populated with "job titles" (that are stored in the same table as contacts info). So both list boxes are populated. When a job title is clicked the employee personell list box is further filtered to show only those at that company with that job title.

The code I have is as follows, and I can't figure out where to embed the additional code for the second list box:

Private Sub Form_Current()
On Error Resume Next

If IsNull(cboPersonell.Value) Then
grpCompany.Value = Null
End If

' Synchronise country combo with existing city
strCompany = DLookup("[Company]", "tblContacts", "[ID]='" &

cboPersonell.Value & "'")
Select Case strCompany1
Case "Company1"
grpCompany.Value = 1
Case "Company2"
grpCompany.Value = 2
Case "Company3"
grpCompany.Value = 3
Case "Company4"
grpCompany.Value = 4
End Select
' Synchronise Personell combo with existing Company
cboPersonell.RowSource = "Select tbl Contacts.ID, tblContacts.L_Name, tblContacts.F_Name " & _
"FROM tblContacts " & _
"WHERE tblContacts.Company = '" & strCompany & "' " & _
"ORDER BY tblContacts.L_Name;"

End Sub

Private Sub grpCompany_AfterUpdate()
On Error Resume Next
Dim strCompany As String

Select Case grpCompany.Value
Case 1
strCompany = "Company 1
Case 2
strCompany = "Company 2"
Case 3
strCompany = "Company 3"
Case 4
strCompany = "Company 4"
End Select
cboPersonell.RowSource = "Select tblContacts.ID, tblContacts.L_Name, tblContacts.F_Name " & _
"FROM tblContacts " & _
"WHERE tblContacts.Company = '" & strCompany & "' " & _
"ORDER BY tblContacts.L_Name;"

End Sub

Any ideas?

I have a form called frmHotspots and dependant on which mainframe system table the user selects from a combo box above called ComboTable, I want the list box below called MyList to be populated with the field names of that system table. Each mainframe system table has its own table in my DB with 1 record in it just so that the field names can be picked up in the DB. For example if the user selects the table called TWA001_Transaction from the ComboTable field above i, I want the code to look within the DB find an Access table called TWA001_Transaction and populate Mylist listbox with the Access field names from that table:

NO_OF_NARR_LINES (this is 2 of the field names in the table there are actually loads of fields in TWA001_transaction

I have attached the code which is a module called AddItemToEnd Currently the "select from" bit is hardcoded with TWA001_Transaction but this should be variable

In the OnCLick properties of Mylist listbox I have put the following code:


I'm obviously doing something majorly wrong as nothing happens when I click on Mylist

I then tried putting


into the Rowsource of the ListBox (with RowSourceType as Value List) but all this did is display =AddItemToEnd([«ctrlListBox»],[«strItem»]) as text in the ListBox
Any help from you clever people would be much appreciated



Hi Everyone,

I need help with a function I am trying to create. I have a table(table1) with three columns, and about 100 rows. I have a form(form1) with a listbox(listbox1) that populates itself using an SQL statement. It only calls for column A out of the three (A,B,C …..) to show in the list box. I need the function to execute some code based on what the user has selected from the multi-select listbox1. Heres kind of the layout I have, I had more, but it just looks more confusing, and I might have been heading in the wrong direction. Can someone please help me convert this pseudocode I wrote… I'm not that familiar with DAO and recordset and all that syntax so that’s where I am ultimately stuck I guess. I had a recordset.EOF loop in my code at one time, if that helps someone understand what I am trying to do, then again I could have been way off..

Dim x As Integer
For x = 0 To listbox1.ListCount - 1
If listbox1.Selected(x) Then
' pull equivalent DAO fields from its control TABLE!
' i need two variables stored from each selection
'example: columns are A B C in the TABLE are present,
'i want to store A in one variable name and C in another
'for each selection of A (which happens to be the only column
'populating listbox1)

' execute code for each selected A from listbox 1 involving, its A variable and same
'row corresponding C field variable
End If
Next x

I would really appreciate it if someone can help me.

Not finding an answer? Try a Google search.