Hi all
I really have hunted for this first! Surprisingly I havn't found a solution.
I want to save NOW() (i.e. Date and time) into an event log file. But I just cannot work out the syntax. My insert statement works fine without the date field in, but fails on a syntax error (3134) when I include it.
strsqlac = "INSERT INTO EventLog ( EventTime, User, EventType, EventMessage, DocRef, AutoSeq, CoCode ) " & _
" Values ( '" & Now() & "', '" & GlobUser & _
"', '" & Mess2 & _
"', '" & Mess1 & _
"', '" & Docref & _
"', " & AutoSeq & _
", '" & CoCode & _
"' );"
... it's the first column, EventTime that is the issue. I have tried several different ways of wrapping it in the VALUES () without success.
My database field EventTime is defined as a General date which Access 2007 tells me will give me date and time. That's what I want.
The Value formats I have tried (currently showing as 'NOW()' above, are ...
#NOW()#
#'NOW()'=
'#NOW()#'
and (as I say) 'NOW()'
I picked all of these suggestions up by Googling and looking on here, but not none of them work for me.
Should I perhaps do a string conversion and save that? It seems daft to have to.
I really have hunted for this first! Surprisingly I havn't found a solution.
I want to save NOW() (i.e. Date and time) into an event log file. But I just cannot work out the syntax. My insert statement works fine without the date field in, but fails on a syntax error (3134) when I include it.
strsqlac = "INSERT INTO EventLog ( EventTime, User, EventType, EventMessage, DocRef, AutoSeq, CoCode ) " & _
" Values ( '" & Now() & "', '" & GlobUser & _
"', '" & Mess2 & _
"', '" & Mess1 & _
"', '" & Docref & _
"', " & AutoSeq & _
", '" & CoCode & _
"' );"
... it's the first column, EventTime that is the issue. I have tried several different ways of wrapping it in the VALUES () without success.
My database field EventTime is defined as a General date which Access 2007 tells me will give me date and time. That's what I want.
The Value formats I have tried (currently showing as 'NOW()' above, are ...
#NOW()#
#'NOW()'=
'#NOW()#'
and (as I say) 'NOW()'
I picked all of these suggestions up by Googling and looking on here, but not none of them work for me.
Should I perhaps do a string conversion and save that? It seems daft to have to.