Prev: Where are Mod's defined in databases
Next: Running a query against a password protected spreadsheet
From: Jay on 18 Mar 2010 23:18 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 19 Mar 2010 00:11 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 19 Mar 2010 00:46 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 19 Mar 2010 09:26 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
|
Pages: 1 Prev: Where are Mod's defined in databases Next: Running a query against a password protected spreadsheet |