I'm using the following code to filter a report by using a multi-select box.
I have a report that contains a subreport. The report is simply an image of a word document. The subreport will contain the actual data.
When I open the subreport, the IN query works perfectly. When I open the main report, I only get the first record listed in the IN query. I have the master/child links set properly.
I've searched and fiddled and can't figure this out.
Code:
Private Sub cmdOpenReport_Click()
On Error GoTo Err_cmdOpenReport_Click
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.ManifestList.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 manifest"
Exit Sub
End If
'add selected values to string
Set ctl = Me.ManifestList
For Each varItem In ctl.ItemsSelected
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 "rptManifestLetterToState", acPreview, , "ManifestDataIDPK IN(" & strWhere & ")"
Exit_cmdOpenReport_Click:
Exit Sub
Err_cmdOpenReport_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReport_Click
End Sub
I have a report that contains a subreport. The report is simply an image of a word document. The subreport will contain the actual data.
When I open the subreport, the IN query works perfectly. When I open the main report, I only get the first record listed in the IN query. I have the master/child links set properly.
I've searched and fiddled and can't figure this out.