G
Guest
In the Microsoft example, How to Filter a Report from a Pop-Up Form, I'm
trying to filter different data types. The example works great for text
values, but when I try to use it on numerical values or date values I get the
following error message:
Data type mismatch in criteria expression
Private Sub Command28_Click()
Dim strSQL As String, intCounter As Integer
'Build SQL String
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " =
" & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
'Strip Last " And "
strSQL = left(strSQL, (Len(strSQL) - 5))
'Set the Filter property
Reports![WorkorderFilterReport].Filter = strSQL
Reports![WorkorderFilterReport].FilterOn = True
Else
Reports![WorkorderFilterReport].FilterOn = False
End If
End Sub
Private Sub Command29_Click()
Dim intCouter As Integer
For intCouter = 1 To 5
Me("Filter" & intCouter) = ""
Next
End Sub
Can this be altered to accept any data type? Or, is the problem with the
configuration of each combo-box?
Thx.
trying to filter different data types. The example works great for text
values, but when I try to use it on numerical values or date values I get the
following error message:
Data type mismatch in criteria expression
Private Sub Command28_Click()
Dim strSQL As String, intCounter As Integer
'Build SQL String
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " =
" & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
'Strip Last " And "
strSQL = left(strSQL, (Len(strSQL) - 5))
'Set the Filter property
Reports![WorkorderFilterReport].Filter = strSQL
Reports![WorkorderFilterReport].FilterOn = True
Else
Reports![WorkorderFilterReport].FilterOn = False
End If
End Sub
Private Sub Command29_Click()
Dim intCouter As Integer
For intCouter = 1 To 5
Me("Filter" & intCouter) = ""
Next
End Sub
Can this be altered to accept any data type? Or, is the problem with the
configuration of each combo-box?
Thx.