Multi list box

  • Thread starter Thread starter Dimitris Nikolakakis
  • Start date Start date
D

Dimitris Nikolakakis

I have a list box and I use it as parameter to a report:
FILTER = [Forms]![ROrders].[List2]=StatusID

If i change the list box to multiselect how can I use the FILTER?

thanks
 
Here's an example that uses the Northwind sample database. The list box
(lstCategory) is bound to the Categories table, and the report (rptProducts)
is bound to the Products table.

Private Sub cmdReport_Click()

Dim varLoop As Variant
Dim strWhere As String

If Me!lstCategory.ItemsSelected.Count = 0 Then
MsgBox "Please select one or more categories"
Else
For Each varLoop In lstCategory.ItemsSelected
strWhere = strWhere & "CategoryID = " &
lstCategory.ItemData(varLoop) & " OR "
Next varLoop
If Right$(strWhere, 4) = " OR " Then
strWhere = Left$(strWhere, Len(strWhere) - 4)
End If
DoCmd.OpenReport "rptProducts", acViewPreview, , strWhere
End If

End Sub
 
Back
Top