syntax error

G

Guest

I'm tyring to using the following statement and get a syntax error:

DoCmd.RunSQL "UPDATE[Table1] set[Date] = Null WHERE [Stock Number] = '" &
strA & "'"

What is wrong with this statement? I'm trying to update a table where the
"Stock Number" in the table is equal to a variable (based on the stock
number).

Thanks for the help........
 
D

Dave Patrick

Try;
DoCmd.RunSQL "UPDATE[Table1] set[Date] = Null WHERE [Stock Number] = '" &
strA & "'; "

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| I'm tyring to using the following statement and get a syntax error:
|
| DoCmd.RunSQL "UPDATE[Table1] set[Date] = Null WHERE [Stock Number] = '" &
| strA & "'"
|
| What is wrong with this statement? I'm trying to update a table where the
| "Stock Number" in the table is equal to a variable (based on the stock
| number).
|
| Thanks for the help........
| --
| JT
 
G

Guest

Is [Stock Number] alphanumeric or just numeric? If it's strictly numeric,
you don't use the single quotes.

Randall Arnold
 
T

Tim Ferguson

DoCmd.RunSQL "UPDATE[Table1] set[Date] = Null WHERE [Stock Number] =
'" & strA & "'"

Don't know if it's just me, but this comes with lots of blanks missing.
Try this:

jetSQL = "UPDATE Table1 " & vbCrLF & _
"SET [Date]=NULL" & vbCrLf & _
"WHERE [Stock Number]=""" & strA & """;"

Oh, and always check your inline code:

Debug.Assert vbYes = MsgBox( _
jetSQL, vbYesNo, "Is this okay?")

And then run it with safety checks on:

CurrentDB().Execute jetSQL, dbFailOnError


By the way, you would find life much easier if you paid a bit more
attention to you field naming system...

All the best


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top