One way I like to do stuff like this is have a temp table and a listbox on the right side of the form with the rowsource based on the temp table. Then I put 2 arrow buttons between the 2 listboxes on the form, one which points to the left listbox (i.e. remove item) and one which points to the right listbox (i.e. add item). The user clicks an item in the listbox and then clicks the add item button which then runs some code to add that item to temp table and hence, show it on the right listbox. If the user selects an item in the right listbox and then the remove item button, I run code to delete the selected item from the temp table. Then any queries or reports simply join on the temp table to retrieve the records of the items selected.
Other than that, if you have a listbox where the user selects multiple items, to retrieve the items selected you need to walk through the collection of the listbox, storing the items selected into a variable.
Dim QItem as string (variable to hold listbox items selected)
Dim ctlList As Control
Dim i As Integer
Set ctlList = me!ListBoxItems
For i = 0 To ctlList.ListCount - 1
If ctlList.Selected(i) = True Then
If QItem = "" then
QItem = ctlList.ItemData(i)
QItem = QItem & ", " & ctlList.ItemData(i)
msgbox "You have selected the following: " & QItem
Last edited by pkstormy; 02-18-08 at 18:00.
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)