Trouble with a DateAdd function in a RunSQL

G

Guest

I have a Query than using a DateAdd Function to add one year to the date
WHERE (((DateAdd("yyyy",1,[tblMailingList]![DateOfLastFlyer])<Date()))
If I run it as a query its work OK, but if I set it up as a string
Dim StrSQL AS String and do a
DoCmd.RunSQL.StrSQL it stops at the “yyyyâ€
I see why its doing this but I don’t know a way to fix it?
Can it be fixed or should I just keep running the query the way I have been?
 
D

Douglas J. Steele

How are you assigning the SQL to StrSQL?

To put a double quote into a string, you need to put two double quotes in a
row in VBA.

StrSQL = "SELECT Field1, Field2 FROM Table1 " & _
"WHERE
(((DateAdd(""yyyy"",1,[tblMailingList]![DateOfLastFlyer])<Date()))"
 

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