Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Update syntax error?

Geek News

Update syntax error?
h3llz 12/10/2008 8:51:01 PM
"UPDATE tblBaskets SET timestamp='" & Now() & "' WHERE basketID=" & basketID
& ";"

if i update the timestamp it gives a syntax error :< timestamp is Date/Time
with general date
Re: Update syntax error?
"Dirk Goldgar" <dg[ at ]NOdataSPAMgnostics.com.invalid> 12/10/2008 9:32:02 PM
"h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
news:BC7EEE20-A862-4C80-ACD2-F58F9042E6BD[ at ]microsoft.com...
[Quoted Text]
> "UPDATE tblBaskets SET timestamp='" & Now() & "' WHERE basketID=" &
> basketID
> & ";"
>
> if i update the timestamp it gives a syntax error :< timestamp is
> Date/Time
> with general date


Use the # delimiter with date/time values:

"UPDATE tblBaskets SET timestamp=#" & _
Now() & "# WHERE basketID=" & basketID & ";"

Note, though, that the date will be interpreted as being in month/day/year
format if that interpretation results in a valid date, even if you are
accustomed to day/month/year format.

You should probably explicitly format the Now() value to avoid any
ambiguity:

"UPDATE tblBaskets SET timestamp=#" & _
Format(Now(), "mm/dd/yyyy hh:nn:ss") & _
"# WHERE basketID=" & basketID & ";"


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Re: Update syntax error?
fredg <fgutkind[ at ]example.invalid> 12/10/2008 9:41:44 PM
On Wed, 10 Dec 2008 12:51:01 -0800, h3llz wrote:

[Quoted Text]
> "UPDATE tblBaskets SET timestamp='" & Now() & "' WHERE basketID=" & basketID
> & ";"
>
> if i update the timestamp it gives a syntax error :< timestamp is Date/Time
> with general date

Dates are delimitated with the # symbol, i.e.
timestamp = #12/10/2008 12:50:00 PM#

Your code delimits the Now() as though it were a string (text) value.

Try:

"UPDATE tblBaskets SET tblBaskets.timestamp= #" & Now() & "# WHERE
basketID=" & basketID & ";"

The above should be all on one line.


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net