Multi list box

  • Thread starter Dimitris Nikolakakis
  • 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
 
B

Brendan Reynolds \(MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top