Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type Mismatch error

Status
Not open for further replies.

btrini10

IS-IT--Management
Dec 5, 2006
73
US
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.
 
If your id is numeric you don't need to surround it with single quotes.



Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top