Date Error

  • Thread starter Thread starter G Lam
  • Start date Start date
G

G Lam

Hi, In a form, I made an unbound control (rptdate) for user to enter a date
and the a button to print report with the date as filter.
For the click button event, I wrote the code like this:
DoCmd.OpenReport "RptshowOrd", acNormal, "qryShowOrd", "OrdDate = #
me.rptdate#"
Error: Syntax error in date in query expression '(OrdDate = #me.rptdate#)'
I tried
"orddate = & #me.rptdate#&"
""" & # me.rptdate # & """"
"OrdDate = #me.rptdate#"
"OrdDate = "" &#rptdate#&"""
but none worked.
How can I get this done?
Thank you.
Gary
 
If the default date format for your region is mm/dd/yyy, use:

"OrdDate = #" & Me.rptdate & "#"

If your date format is different from the above, use:

"OrdDate = " & Format(Me.rptdate, "\#mm/dd/yyyy\#")

It may be necessary to set a date format on the unbound Control so that
Access recognise the entry in the unbound Control is meant to be date.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top