From: Jay on
I have code in a module as follows:

strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = " & Now
DoCmd.RunSQL strSql

The field email_LastDateSent is a Date field. I get an error message
"Syntax error (missing operator)" What syntax am I missing.

Thanks
From: ChrisJ on

try...

strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = #" & Now & "#"

the hashes are needed for dates just like quotes are needed for strings

"Jay" wrote:

> I have code in a module as follows:
>
> strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = " & Now
> DoCmd.RunSQL strSql
>
> The field email_LastDateSent is a Date field. I get an error message
> "Syntax error (missing operator)" What syntax am I missing.
>
> Thanks
>
From: Jay on
Thanks Chris,

Will this then post the time portion as well as I would like the date
and time in the same field.

-----Original Message-----
From: ChrisJ [mailto:ChrisJ(a)discussions.microsoft.com]
Posted At: Thursday, March 18, 2010 9:11 PM
Posted To: microsoft.public.access.queries
Conversation: SQL Update and NOW
Subject: RE: SQL Update and NOW



try...

strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = #" & Now
& "#"

the hashes are needed for dates just like quotes are needed for strings

"Jay" wrote:

> I have code in a module as follows:
>
> strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = " & Now
> DoCmd.RunSQL strSql
>
> The field email_LastDateSent is a Date field. I get an error message
> "Syntax error (missing operator)" What syntax am I missing.
>
> Thanks
>

From: Bob Barrows on
Jay wrote:
> I have code in a module as follows:
>
> strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = " & Now
> DoCmd.RunSQL strSql
>
> The field email_LastDateSent is a Date field. I get an error message
> "Syntax error (missing operator)" What syntax am I missing.
>
Simply change it to:
strSql = "Update tbl_admin Set tbl_admin.email_LastDateSent = Now()"

There is no need for the concatenation. Jet is perfectly capable of
running the Now function.

And yes, Now returns time as well as date. To get date-only, use the
Date function.
--
HTH,
Bob Barrows