vickiwells
Registered User.
- Local time
- Today, 23:12
- Joined
- Jun 30, 2000
- Messages
- 61
I have a report based on a table, not a query.I need a dialog box to filter it from. I found an example in the Developer's handbook, but can't get it to work for more than the first selection. Could someone check this to see what's wrong? I'm using 2000.
Private Sub cmdPreview_Click()
Dim vntItem As Variant, strFilter As String
Dim rptMyReport As New Report_Ledger
For Each vntItem In Me!List0.ItemsSelected
' Concatenate single quotes around the Job #
' because the Job # field is Text.
strFilter = strFilter & "[Job #] = '" & _
Me![List0].ItemData(vntItem) & "' OR "
Next
' Remove the OR string from the end of the filter
' condition if a filter exists.
If strFilter <> "" Then
strFilter = Left(strFilter, Len(strFilter) - 4)
End If
' Preview the report, and pass the filter string
DoCmd.OpenReport rptMyReport.Name, acPreview, , strFilter
End Sub
I'm not sure what the part at the bottom is for-where it's got the -4. Do I need it? My filtered field is a text field, but I don't know what the code is doing there. Also, it won't let me put brackets around "Report_Ledger" in the dimReport MyReport line.
Private Sub cmdPreview_Click()
Dim vntItem As Variant, strFilter As String
Dim rptMyReport As New Report_Ledger
For Each vntItem In Me!List0.ItemsSelected
' Concatenate single quotes around the Job #
' because the Job # field is Text.
strFilter = strFilter & "[Job #] = '" & _
Me![List0].ItemData(vntItem) & "' OR "
Next
' Remove the OR string from the end of the filter
' condition if a filter exists.
If strFilter <> "" Then
strFilter = Left(strFilter, Len(strFilter) - 4)
End If
' Preview the report, and pass the filter string
DoCmd.OpenReport rptMyReport.Name, acPreview, , strFilter
End Sub
I'm not sure what the part at the bottom is for-where it's got the -4. Do I need it? My filtered field is a text field, but I don't know what the code is doing there. Also, it won't let me put brackets around "Report_Ledger" in the dimReport MyReport line.