G
Guest
I am trying to filter a report dynamically by a pop-up form. Here is the code I use to create the SQL expression.
For intCounter = 1 To 3
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
strSQL = Left(strSQL, (Len(strSQL) - 5))
Reports![RPT-PNDynamic].Filter = strSQL
Reports![RPT-PNDynamic].FilterOn = True
End If
There is no problem to create the SQL expression but one of the fields I want to filter is a Date/Time type in the Table. So when it goes to apply the SQL expression, I receive the following error message: Data Type mismatch in criteria expression. Access does not want to match the SQL expression (string Type) with the Date/Time Type, which is not a big surprise. How can I get this to work?
I am using Access 97
For intCounter = 1 To 3
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
strSQL = Left(strSQL, (Len(strSQL) - 5))
Reports![RPT-PNDynamic].Filter = strSQL
Reports![RPT-PNDynamic].FilterOn = True
End If
There is no problem to create the SQL expression but one of the fields I want to filter is a Date/Time type in the Table. So when it goes to apply the SQL expression, I receive the following error message: Data Type mismatch in criteria expression. Access does not want to match the SQL expression (string Type) with the Date/Time Type, which is not a big surprise. How can I get this to work?
I am using Access 97