Help! Wherecondition date nightmare

R

Rivers

ok im starting to get the hang of passing queries through the wherecondition
instead of queries but this one has me stumped

my code
Dim stDocName, strdate As String
strdate = "[Date to Arrive] =" & Me![Text28]

stDocName = "Time Details1"
DoCmd.OpenReport stDocName, acPreview, , strdate

i added a watch to strdate which comes back
"[Date to Arrive] = 19/10/2007"

so i no that its picking up the correct date however the report returns
blank!!!
i know the records are there for this date so i checked if the date
formating was the same this checked out the same as well. im stumped stuck
and starting to get well you get the jist

any help would be great
 
A

Allen Browne

You're on the right track, but the literal date in the SQL string needs to
be formatted American, and delimited with #.

Try:
strdate = "[Date to Arrive] =" & Format(Me![Text28] "\#mm\/dd\/yyyy\#")

For an explanation, see section 2 of this article:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html

(There is also the possibity that your [Date to Arrive] field may have a
time as well as a date.)
 
M

Marshall Barton

Rivers said:
ok im starting to get the hang of passing queries through the wherecondition
instead of queries but this one has me stumped

my code
Dim stDocName, strdate As String
strdate = "[Date to Arrive] =" & Me![Text28]

stDocName = "Time Details1"
DoCmd.OpenReport stDocName, acPreview, , strdate

i added a watch to strdate which comes back
"[Date to Arrive] = 19/10/2007"

so i no that its picking up the correct date however the report returns
blank!!!
i know the records are there for this date so i checked if the date
formating was the same this checked out the same as well

A date value in a string that Access will process needs to
be enclosed in # signs:

You code should be like:

strdate = "[Date to Arrive] =" & Format(Me![Text28],
"\#yyyy-m-d\#")
 

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