469,275 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

DateValue() nor working

Hi.

Why is this DAO line producing error 3077 (Syntax error in number in
expression)?

rst.FindFirst "ValidFrom = " & DateValue(varDate)

rst is a defined recordset
varDate is a valid date.
ValidFrom is a valid field of the underlying table.

This line works!
rst.FindFirst "ValidFrom = #01,01,2000#"

TIA

--
Georges

Nov 12 '05 #1
3 1749
Georges Heinesch wrote:
Hi.

Why is this DAO line producing error 3077 (Syntax error in number in
expression)?

rst.FindFirst "ValidFrom = " & DateValue(varDate)

rst is a defined recordset
varDate is a valid date.
ValidFrom is a valid field of the underlying table.

This line works!
rst.FindFirst "ValidFrom = #01,01,2000#"


You need to delimit the date returned by DateValue(). It returns
a Variant (of subtype Date) so try this:

rst.FindFirst "ValidFrom = #" & DateValue(varDate) & "#"

But if varDate is a valid Date field then all you need to do is:

rst.FindFirst "ValidFrom = #" & varDate & "#"

--
'-------------------------------
' John Mishefske
'-------------------------------

Nov 12 '05 #2
John Mishefske wrote:
You need to delimit the date returned by DateValue(). It returns
a Variant (of subtype Date) so try this:

rst.FindFirst "ValidFrom = #" & DateValue(varDate) & "#"

But if varDate is a valid Date field then all you need to do is:

rst.FindFirst "ValidFrom = #" & varDate & "#"


Thanks for your reply.
Both of your suggestions were tested already before.
Both produced error 3077.

varDate is valid.
print.debug varDate says "01.01.2000"

I have no clue what goes wrong here!

--
Georges

Nov 12 '05 #3
Georges Heinesch wrote:
Thanks for your reply.
Both of your suggestions were tested already before.
Both produced error 3077.

varDate is valid.
print.debug varDate says "01.01.2000"

I have no clue what goes wrong here!


I found the error! In fact, the date was not formatted according to the
american system (but due to the locale settings, to the european
system). The code below did the job:

"ValidFrom < #" & Format(varDate, "mm\/dd\/yyyy") & "#"

Thanks.

--
Georges

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.