Update query with date fragment

  • Thread starter Thread starter Mark
  • Start date Start date
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
 
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
 
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.
 
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
.
.
 
Back
Top