Update query with date fragment

M

Mark

Hi,
I'm trying to update a table based depending upon if a
report has been run or needs to be run, using the
following query:

DoCmd.RunSQL "UPDATE tblReport SET tblReport.RunComplete =
Yes WHERE (((tblReport.RunComplete)=0) AND ((DatePart("m",
Date())) = [RunDate]));"

But I keep getting an "Expected end of statement" compile
error on "m" in the query string. What am I doing wrong?
Any help would be greatly appreciated. Thanks!
Mark
 
C

chris

Change the double quotes around the m to single quotes.
The double quote before the m is being taken as the end of
the query
 
J

John Vinson

Hi,
I'm trying to update a table based depending upon if a
report has been run or needs to be run, using the
following query:

DoCmd.RunSQL "UPDATE tblReport SET tblReport.RunComplete =
Yes WHERE (((tblReport.RunComplete)=0) AND ((DatePart("m",
Date())) = [RunDate]));"

But I keep getting an "Expected end of statement" compile
error on "m" in the query string. What am I doing wrong?
Any help would be greatly appreciated. Thanks!
Mark

That's because the " before the m is being interpreted as the closing
quotemark for the quoted string which begins before Update.

Use ""m"" or 'm' instead of "m" and you should be OK.
 
M

Mark

Thanks, Chris, it worked like a charm!
Mark
-----Original Message-----
Change the double quotes around the m to single quotes.
The double quote before the m is being taken as the end of
the query
-----Original Message-----
Hi,
I'm trying to update a table based depending upon if a
report has been run or needs to be run, using the
following query:

DoCmd.RunSQL "UPDATE tblReport SET tblReport.RunComplete =
Yes WHERE (((tblReport.RunComplete)=0) AND ((DatePart ("m",
Date())) = [RunDate]));"

But I keep getting an "Expected end of statement" compile
error on "m" in the query string. What am I doing wrong?
Any help would be greatly appreciated. Thanks!
Mark
.
.
 

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

Similar Threads


Top