Re: sql syntax error
- From: MGFoster <me@xxxxxxxxxxx>
- Date: Tue, 07 Apr 2009 13:47:47 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I just noticed in your original post that there isn't a space between
INTO and the name of your table - please insert one.
The red highlight is a VBA error indication, not a SQL syntax error.
Therefore, the string probably isn't properly formatted for VBA. My
guess is that you don't have line-end indicators. Try this string [this
assumes the ChangeDate's Default is set to =Date()]:
SQL = "INSERT INTO lkpStatusChanges (SiteRef, [status], " & _
"ChangedBy) VALUES(" & iRef & ",'" & sStatus & _
"','" & sBy "')"
Note the & _ at the end of the line - this indicates the string
continues on the next line.
HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBSdu7wIechKqOuFEgEQLCtACdE5bVDdMVcqJ98QhOzI/ecrIQn/AAoMEu
kJ+Qiq3BuQ38TZ5UmyOgFOAo
=8eF+
-----END PGP SIGNATURE-----
paul wrote:
Sorry, to be clear the following line is highlighted in red before.
i've run anything so no even getting to the debug stage. dToday is a
date formatted, with #'s using the SQLDate function i found on this
group.
Ive tried taking the date out of the insert statement and setting the
default table value to Date but the line is still hightlighted red!
Any other ideas?
Thanks again
Paul
On Apr 3, 5:28 pm, MGFoster <m...@xxxxxxxxxxx> wrote:paul wrote:Hi im getting a syntax error on the following and cant figure out-----BEGIN PGP SIGNED MESSAGE-----
where i've gone wrong, any suggestions?
SQL = "insert intolkpStatusChanges
(SiteRef,status,ChangeDate,ChangedBy) values (" & iRef & ",'" &
sStatus & "'," & dToday & ",'" & sBy "')"
DoCmd.RunSQL sSQL
Hash: SHA1
You may want to put [] brackets around the word status since it is a SQL
reserved word; also put # delimiters around the date value, though it
should not be causing a problem.
... "',#" & dToday & "#,'" ....
And, use the newer Execute method:
CurrentDb.Execute sSQL, dbFailOnError
For the ChangeDate you could set the table Default values to =Date() or
=Now(). That way you wouldn't have to include it in an INSERT command.
Unfortunately, Access won't allow the CurrentUser() function in the
Default for ChangedBy - it doesn't recognize its own built-in function!
HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBSdY5NIechKqOuFEgEQKLUQCfWsBkAoaEZF5Wi0LSBTg3UEaZyxkAnR6u
yHvKBF6HujpGtIZS8AlKCo+N
=ogDO
-----END PGP SIGNATURE-----
- References:
- sql syntax error
- From: paul
- Re: sql syntax error
- From: MGFoster
- Re: sql syntax error
- From: paul
- sql syntax error
- Prev by Date: Re: restrict data entry until fields are complete
- Next by Date: Vista 32 vs 64
- Previous by thread: Re: sql syntax error
- Next by thread: Re: Data is coming in different language
- Index(es):
Relevant Pages
|