For a multi-select list box, you have to loop through the list box and accummulate the selections into a variable and then pass that to the query. I typically build the query in code as well.
Here is a code snippet that does that:
Code:
Dim lngloop as long
Dim strWhere as string
Dim strIDs as string
If Me.projtype.ItemsSelected.Count <> 0 Then
If Me.projtype.ItemsSelected.Count > 0 Then
For lngLoop = 0 To Me.projtype.ItemsSelected.Count - 1
If lngLoop = 0 Then
strIDs = strIDs & Me.projtype.ItemData(Me.projtype.ItemsSelected(lngLoop))
Else
strIDs = strIDs + "," & Me.projtype.ItemData(Me.projtype.ItemsSelected(lngLoop))
End If
Next lngLoop
End If
strWhere = strWhere & "tblProjLog.fkProjType in (" & strIDs & ") AND "
strIDs = ""
End If
The list box in the above is called projtype. The bound field of the list box is the primary key of the table which is the row source of the list box. For each item that is selected in the list box, the code will take the key value and put it in the variable called strIDs. The nested IF..ELSE...ENDIF checks to see if the selection is the first selection, if so it puts the value directly in strIDs. Each subsequent time through the loop if a selected item is found, a comma is added and then the value. So you will end up with a string that look like this: 1,3,6
You would then use the strIDs variable in constructing the WHERE clause of the query (strWhere).
You would then bring a variable that has the appropriate SELECT & FROM clause and concatenate the strWhere variable to that to create your query.
You would then use the query as the record source for the form that displays the search results & open the form