Hi AB
Generally you would have (at least) two columns in such a list box. The
bound column would contain the primary key of your Customers table
(CustomerID) and the second column would show the customer name. It would
be normal to set the width of the first column to zero, so that the list
appeared to have only one column - CustomerIDs are often "messy" numbers
which are of no interest to the user.
The trick is then to enumerate the ItemsSelected collection of the listbox
and construct a string, so you can filter using an IN operator:
Dim vItem as Variant
Dim sList as string
For Each vItem In lstCustomers.ItemsSelected
sList = sList & lstCustomers.ItemData(vItem) & ","
Next vItem
' remove the last comma
If Len(sList)<>0 then sList = Left(sList, Len(sList)-1)
DoCmd.OpenReport "MyReport", , , "[CustomerID] IN (" & sList & ")"
I don't know what you've tried, but if you are still having trouble then
post back the code.
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
AB said:
I have a listbox with a couple hundred customers. I want to be able to use
the listbox to limit my report to the selected customers. How can I do
this?
I did try to follow Browne's tutorial on this but the tutorial uses a
two-column listbox, which doesn't apply to my case.
And guidance would be greatly appreciated.