Hi!, I need a little help please, here is my problem:
I've created a report and Its composed by 3 sub-strings that generate a final string that filter a report. 2 of these sub-strings are text, and they work fine, but the other sub-string is a number and when I try to use this string (to sort the data by year, by the way) I get the following error:
"Data type mismatch in criteria expression"
I know that I have to define that its a number and not text, but I dont know how:
' Build criteria string from lstYear listbox
For Each varItem In Me.lstYear.ItemsSelected
strYear = strYear & ",'" & Me.lstYear.ItemData(varItem) _
& "'"
Next varItem
If Len(strYear) = 0 Then
strYear = "Like '*'"
Else
strYear = Right(strYear, Len(strYear) - 1)
strYear = "IN(" & strYear & ")"
End If
Your help would be greatly appreciated!
Thanks!
I've created a report and Its composed by 3 sub-strings that generate a final string that filter a report. 2 of these sub-strings are text, and they work fine, but the other sub-string is a number and when I try to use this string (to sort the data by year, by the way) I get the following error:
"Data type mismatch in criteria expression"
I know that I have to define that its a number and not text, but I dont know how:
' Build criteria string from lstYear listbox
For Each varItem In Me.lstYear.ItemsSelected
strYear = strYear & ",'" & Me.lstYear.ItemData(varItem) _
& "'"
Next varItem
If Len(strYear) = 0 Then
strYear = "Like '*'"
Else
strYear = Right(strYear, Len(strYear) - 1)
strYear = "IN(" & strYear & ")"
End If
Your help would be greatly appreciated!
Thanks!