Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with DLookup Syntax

Status
Not open for further replies.

theSizz

Technical User
Apr 22, 2002
93
0
0
US
I put this expression in the QBE grid’s criteria row of a select query.
What I’m trying to accomplish is have a query use for its criteria today’s date in other words I want the date the criteria uses to be dynamic.

This is the expression that produces the error.
=DLookUp("[Period]","tblDates","[ComboDt] = # Now () #")

If I write it this way:
=DLookUp("[Period]","tblDates","[ComboDt] = # 12/21/07 #")

No problem.

Can someone help provide the correct syntax to have the criteria based on the current day’s date return the proper records?

Thanks in advance.


 
[tt]=DLookUp("[Period]","tblDates","[ComboDt] = #" & Now() & " #")[/tt]

Now() includes time to the second, so Date() or a format may be better.
 
Yes Remou that's the problem why the query doesn't return any records. I didn't realize that Now() returns time to the second. So rather than format the expression I'm using Date()like you suggested and it works fine.

Thanks for the quick reply.

theSizz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top