multi-listbox query

luvbite38

Active Member
Joined
Jun 25, 2008
Messages
368
hi guys,

I am using the following code (which I obtained from Multi-Select Listbox)


Code:
Private Sub cmdOpenReport_Click()
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.CList.ItemsSelected.Count = 0 Then
  MsgBox "Must select at least 1 employee"
  Exit Sub
End If
'add selected values to string
Set ctl = Me.CList
For Each varItem In ctl.ItemsSelected
  'strWhere = strWhere & ctl.ItemData(varItem) & ","
  'Use this line if your value is text
  strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
'open the report, restricted to the selected items
DoCmd.OpenReport "Report", acPreview, , "*Client Name IN(" & strWhere & ")"
End Sub

for some reason, I m getting missing syntax error 3075 :( :( :(

10 hours and 20 ciggis and 12 bears and no solution.....

please help :( someone??

Regards,
L
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
thanks J,

I managed to fix it, the error was in report filter

I changed the following line

DoCmd.OpenReport "Report", acPreview, , "*Client Name IN(" & strWhere & ")"

to

DoCmd.OpenReport "Report", acPreview, , "[*Client Name] IN(" & strWhere & ")"


Thanks :)
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,127
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top