You need to enumerate each selected item in the listbox and construct a
WHERE-clause of the form:
[Fieldname] IN (val1, val2, val3, ...)
This code should get you going:
Dim strWhere As String, varItem As Variant
strWhere = "[Fieldname] IN ("
With MyListbox
For Each varItem In .ItemsSelected
strWhere = strWhere & .ItemData(varItem) & ","
Next varItem
End With
' change the last "," to ")"
Mid(strWhere , Len(strWhere ), 1) = ")"
Now you can use strWhere in several different ways:
1. Pass it to OpenForm or OpenReport as a Where-condition
2. Append it to a SQL Select statement to open a recordset
3. Append it to a SQL Update (or Delete, or other) statement to execute
as an action query
4. ...
If [Fieldname] is a text (not numeric) field, then you need to include
quotes around each value:
strWhere = strWhere & """" & .ItemData(varItem) & ""","