Syntax error?

justice8965

Registered User.
Local time
Yesterday, 20:56
Joined
Aug 25, 2009
Messages
32
Hey guys, can anyone tell me whats wrong with my syntax here? Not sure where I'm missing quotes, or whatever it is I'm missing...

PreviousAverage: iif([BeginDate] <= DateAdd("m", -12, Now()), 0, DLookup("[AverageforPeriod]", "qry12month", "[BeginDate] = DateAdd("m", -1, [BeginDate])")

The error is coming from DateAdd, the "m" specifically.
 
"[BeginDate] = DateAdd("m", -1, [BeginDate])")

You cannot wrap " inside ""
Either double " them or ' ...
"[BeginDate] = DateAdd(""m"", -1, [BeginDate])")
or
"[BeginDate] = DateAdd('m', -1, [BeginDate])")
or
"[BeginDate] = #" & DateAdd("m", -1, [BeginDate]) &"#")

Any of the three should work just fine, just hope you now understand what is going on...
 
Yeah I see where my error was, thank you. Used your third suggestion and it works perfectly thanks a lot.
 

Users who are viewing this thread

Back
Top Bottom