applyfilter for calculated fields in reports

  • Thread starter Thread starter Chieko Kuroda
  • Start date Start date
C

Chieko Kuroda

I have been trying for some time to use the applyfilter
on a calculated field. But I keep getting the error
message "datatype mismatch". Would anyone show me how to
correct my code:
Thanks,
Chieko
Private Sub Report_Open(Cancel As Integer)
'Filter out records with length of stay > 2.0

DoCmd.ApplyFilter , "'=([DC_Date]-[Admit_Date])' > 2"
End Sub
 
Chieko said:
I have been trying for some time to use the applyfilter
on a calculated field. But I keep getting the error
message "datatype mismatch". Would anyone show me how to
correct my code:
Thanks,
Chieko
Private Sub Report_Open(Cancel As Integer)
'Filter out records with length of stay > 2.0

DoCmd.ApplyFilter , "'=([DC_Date]-[Admit_Date])' > 2"
End Sub
Put the *name* of the field in the expression, not its *calculation*.
And, I see an expression equivalent to

'somestring' > 2

which is wrong. Probably a simple

"[yourfield] > 2"

will do. If your field does not contain spaces (in the name), the square
brackets are optional.
 
Back
Top