MultiSelect Listbox

mixedguy

Registered User.
Local time
Yesterday, 23:48
Joined
Jun 12, 2002
Messages
52
What I've done:
I've created a list box and have changed it's MultiSelect property from "None" to "Simple." I'm trying to allow users to select more then one item in the listbox. Then I created a query and assigned the listbox to the criteria section of the query. So now what ever the user selects from the listbox should be the parameter of the query.
From there I will create my report based on that query.

Problem:
The query doesn't work. I don't know why the query isn't quering based on the selection in the list box. Can someone please help me.

Thanks!
 
This code opens a form based on the query. The query gets its criteria from a multi-select list box.

For Each varItem In Me![YourListBoxName].ItemsSelected
strWhere = strWhere & "YourFieldName =" _
& Chr(39) & Me![YourListBoxName].Column(0, varItem) & Chr(39) & " Or "
Next varItem

strWhere = Left(strWhere, Len(strWhere) - 4)

DoCmd.OpenForm "YourformName", , , strWhere
 
When you changed the listbox from single to multiple select, the control became "unbound". You can no longer refer to the control to obtain the selected value(s). You need to create a code loop that passes through the SelectedItems collection to obtain the selections. Jack posted sample code for that loop. There are additional code samples in help and in this forum's archives. Search for multi-select.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom