Can anyone help me to get my listbox to function properly. It's on a form to choose which records that I want a report on.
Basically, I know the problem is the code is looking for a number in the RecID field, and that's what's giving me the data mismatch error, but I need the code to look for RecID as a text field.
Any help is appreciated, here's my code:
Option Compare Database
Private Function GetCriteria() As String
Dim stDocCriteria As String
Dim VarItm As Variant
For Each VarItm In ListFilter.ItemsSelected
stDocCriteria = stDocCriteria & "[CarID] = " & ListFilter.Column(0, VarItm) & " OR "
Next
If stDocCriteria <> "" Then
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) - 4)
Else
stDocCriteria = "True"
End If
GetCriteria = stDocCriteria
End Function
Private Sub ButtonOpen_Click()
DoCmd.OpenReport "rpt_CarSales", acPreview, , GetCriteria()
End Sub
Basically, I know the problem is the code is looking for a number in the RecID field, and that's what's giving me the data mismatch error, but I need the code to look for RecID as a text field.
Any help is appreciated, here's my code:
Option Compare Database
Private Function GetCriteria() As String
Dim stDocCriteria As String
Dim VarItm As Variant
For Each VarItm In ListFilter.ItemsSelected
stDocCriteria = stDocCriteria & "[CarID] = " & ListFilter.Column(0, VarItm) & " OR "
Next
If stDocCriteria <> "" Then
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) - 4)
Else
stDocCriteria = "True"
End If
GetCriteria = stDocCriteria
End Function
Private Sub ButtonOpen_Click()
DoCmd.OpenReport "rpt_CarSales", acPreview, , GetCriteria()
End Sub