View Full Version : MultiSelect List Box


Gonzo
12-14-2001, 06:33 AM
Can someone give me a little help with this pesky ListBox. I have this code set up to view reports from selected branches. The problem is that i keep getting an "Enter Parameter Value for BranchIDtitle" and BranchID is the title for that field. What am I missing here? Any ideas?

Private Sub Command158_Click()
Dim varItem As Variant
Dim strWhere As String

For Each varItem In Me!ListBox.ItemsSelected
strWhere = strWhere & "BranchID =" & Me!ListBox.Column(0, varItem) & " Or "
Next varItem
strWhere = Left(strWhere, Len(strWhere) - 4) 'Remove the last " Or "

DoCmd.OpenReport "Report1", acViewPreview, , strWhere

End Sub

Thanks
Gonzo

[This message has been edited by Gonzo (edited 12-14-2001).]

Jack Cowley
12-14-2001, 08:15 AM
Is BranchID/BranchIDtitle numeric or a string?

Gonzo
12-14-2001, 09:06 AM
Oh, it's a string. But i think i got around that problem. Now i'm facing the problem of the Query criteria not using Quotes, but instead using brackets where I have commanded those quotes to go. The Query won't read the variants if they aren't in quotes.

thanks for responding.

Jack Cowley
12-14-2001, 09:14 AM
strWhere = strWhere & "BranchID =" & Chr(39) & Me![List0].Column(0, varItem) & Chr(39) & " Or "

Gonzo
12-14-2001, 09:44 AM
Ahhh,
Thank you. What a headache you have solved.