Filter a report from a Pop-Up Form

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Yanik:

When you concantate date/time variables, they must be wrapped in pound signs
as in:

strSQL & "#" & Date/TimeVar & "#"
 
Currency and number values can simply be concantated with a simply & value
&, text values must be use an apostrophe quoatation pair as in '" & text
value & "' more string "
 
Merci beaucoup! Very appreciated

----- SA wrote: ----

Currency and number values can simply be concantated with a simply & value
&, text values must be use an apostrophe quoatation pair as in '" & text
value & "' more string
 
Back
Top