belovedcej
Programmer
I want to be able to print a report by limiting on particular field value via a multi-select list box.
I used thread703-565398 as a source for this, but there's obviously something I'm missing.
If I do not select anything in the list box, the report prints fine.
If I select something, however, I get the message "Object variable or with block variable not set."
Could someone tell me what I'm doing wrong? Thanks!
I used thread703-565398 as a source for this, but there's obviously something I'm missing.
If I do not select anything in the list box, the report prints fine.
If I select something, however, I get the message "Object variable or with block variable not set."
Could someone tell me what I'm doing wrong? Thanks!
Code:
Dim stDocName As String
Dim varItem As Variant
Dim strList As ListBox
stDocName = "rpt_IN_Services"
If Me.List0.ItemsSelected.Count = 0 Then
DoCmd.OpenReport stDocName, acPreview
Else
For Each varItem In Me.List0.ItemsSelected
strList = strList & ",'" & vaItem & "'"
Next varItem
strList = Mid$(strList, 2)
Report_rpt_IN_Services.RecordSource = "SELECT * FROM qry_IN_Services WHERE [Service] In (" & strList & ")"
DoCmd.OpenReport stDocName, acPreview
End If