Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim strFilter As String
Dim varItem As Variant
For Each varItem In Me!List0.ItemsSelected
strFilter = strFilter & "[ID] = '" & _
Me![List0].ItemData(varItem) & "' OR "
Next
' the next bit of code will subtract out the last "OR"
If strFilter <> "" Then
strFilter = Left(strFilter, Len(strFilter) - 4)
End If
Debug.Print strFilter
' now, run the report using strFilter to pass a string
' containing the needed customers
DoCmd.OpenReport "Report - All Findings", acPreview, , strFilter
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub
Above is VB code I am using to filter my report. However I keep getting a"Data Type mismatch in criteria expression" whenever I run it.
I would appreciate if someone could assist me in finding my error.
Thanks a lot.
On Error GoTo Err_Command5_Click
Dim strFilter As String
Dim varItem As Variant
For Each varItem In Me!List0.ItemsSelected
strFilter = strFilter & "[ID] = '" & _
Me![List0].ItemData(varItem) & "' OR "
Next
' the next bit of code will subtract out the last "OR"
If strFilter <> "" Then
strFilter = Left(strFilter, Len(strFilter) - 4)
End If
Debug.Print strFilter
' now, run the report using strFilter to pass a string
' containing the needed customers
DoCmd.OpenReport "Report - All Findings", acPreview, , strFilter
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub
Above is VB code I am using to filter my report. However I keep getting a"Data Type mismatch in criteria expression" whenever I run it.
I would appreciate if someone could assist me in finding my error.
Thanks a lot.