Date Error

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
 
V

Van T. Dinh

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top