Using DateAdd with DLookup (1 Viewer)

Trocergian

Registered User.
Local time
Yesterday, 19:30
Joined
Apr 6, 2009
Messages
16
I can't seem to get this syntax correct trying to use DateAdd as criteria with DLookup.

Here's what I think it ought to be:

Code:
DLookUp("SumOfHours","qryDailyTotal","[WorkDate]=#" & DateAdd('d',1,gStartDate) & "#")

with gStartDate being a date variable.

However I get "Expected: expression" Where am I going wrong?
 

plog

Banishment Pending
Local time
Yesterday, 19:30
Joined
May 11, 2011
Messages
11,613
Where am I going wrong?

Find out. Isolate and test.

Does the DateAdd expression work? Does it return a date? Isolate and test.
 

missinglinq

AWF VIP
Local time
Yesterday, 20:30
Joined
Jun 20, 2003
Messages
6,423
...I get "Expected: expression" Where am I going wrong?

I guessing it's that...you don't have an expression!

An expression such as

SomeControlName = DLookUp("SumOfHours","qryDailyTotal","[WorkDate]=#" & DateAdd('d',1,gStartDate) & "#")

The

SomeControlName =

part makes it an Expression...without it Access doesn't know what to do with the returned value of the DLookup Function.

Not sure that it really matters, but the Interval Argument ('d') should be in Double Quotes i.e. ("d") not Single Quotes.

Linq ;0)>
 

Trocergian

Registered User.
Local time
Yesterday, 19:30
Joined
Apr 6, 2009
Messages
16
Good grief, I found where I was going off the rails.
I had originally wrote some code in a textbox so the code started out =DLookup(... but what I had wasn't working so I went to testing in the immediate window and didn't notice I was working with ? = DLookup(... there.

Once I realized it and removed the "=" the darn code work. Sorry for wasting your time guys but thanks for the effort.
 

missinglinq

AWF VIP
Local time
Yesterday, 20:30
Joined
Jun 20, 2003
Messages
6,423
Glad you got it working!

Good luck with your project!

Linq ;0)>
 

Users who are viewing this thread

Top Bottom