Hey guys,
I have a report that is filtered based on a multiselect listbox on a form.
which is working fine.
what i want to do is add another multiselect listbox and filter the report based on both listboxes.
which i don't really know how to do.
Here is the code i'm using:
Private Sub Command7_Click()
Dim strReport As String
Dim strWhere As String
Dim lngView As Long
Dim strFilter As String
Dim varItem As Variant
strReport = "Main_DB_Report" 'Put your report name in these quotes.
lngView = acViewPreview 'Use acViewNormal to print instead of preview.
' loop through listbox items selected
For Each varItem In Me!List0.ItemsSelected
strFilter = strFilter & "[country] = '" & _
Me!
[List0].ItemData(varItem) & "' OR "
Next ' continue loop
If strFilter <> "" Then
strFilter = Left(strFilter, Len(strFilter) - 4)
Else
MsgBox "You did not select any Country."
List0.SetFocus
Exit Sub
End If
DoCmd.OpenReport strReport, acViewPreview, , strFilter
End Sub
I've attached the sample database.productiondb.zip