View Full Version : Multiple Select list box info to a report


PMrider
03-02-2002, 10:41 AM
Does anyone have a model on the use of ItemsSelected for list boxes. It will be greatly appreciated.
akolln@srt.com

thanks..
Alan

SimonC
03-02-2002, 11:01 AM
Not quite sure if this is what you're driving at. Assume a multi-select list box (which you want the bound column from) on a form and a command button which opens a report in preview mode. Here's one way:

Private Sub cmdPreview_Click()
Dim lst As ListBox
Dim vItem As Variant, sCriteria As String

sCriteria = ""

Set lst = Me.lstItems

For Each vItem In lst.ItemsSelected
sCriteria = sCriteria & "," & lst.ItemData(vItem)
Next vItem

DoCmd.OpenReport "reportname", acViewPreview, "ID IN (" & Mid(sCriteria, 2) & ")"
End Sub