SQL Syntax

  • Thread starter Thread starter JString
  • Start date Start date
J

JString

Need help with an append query statement that's being run from VBA and
generates an error:

INSERT INTO [Temp6211] (Fields,Operators,Values) VALUES ("PLAINTIFF", "=",
"test")

if anyone can help me, thanks in advance.
 
Need help with an append query statement that's being run from VBA and
generates an error:

INSERT INTO [Temp6211] (Fields,Operators,Values) VALUES ("PLAINTIFF", "=",
"test")

if anyone can help me, thanks in advance.  

Without knowing exactly the error reported, this is a toughy.
However, the first thing that should be done is to substitute
apostrophes for the quotations.
 
Do you mean in VBA only, or should the final statement have apostrophes
instead of quotes? The SQL statement I provided is the return value of my
vba code.

Here's the code:

sqlstr = "INSERT INTO " & sqltblname & " (Fields,Operators,Values) VALUES("
sqlstr = sqlstr & Chr(34) & ctlarray(2, i) & Chr(34) & ", "
sqlstr = sqlstr & Chr(34) & "=" & Chr(34) & ", "
sqlstr = sqlstr & Chr(34) & ctl.Value & Chr(34) & ")"
DoCmd.RunSQL sqlstr


Need help with an append query statement that's being run from VBA and
generates an error:

INSERT INTO [Temp6211] (Fields,Operators,Values) VALUES ("PLAINTIFF", "=",
"test")

if anyone can help me, thanks in advance.

Without knowing exactly the error reported, this is a toughy.
However, the first thing that should be done is to substitute
apostrophes for the quotations.
 
JString said:
Need help with an append query statement that's being run from VBA and
generates an error:

INSERT INTO [Temp6211] (Fields,Operators,Values) VALUES ("PLAINTIFF",
"=", "test")

if anyone can help me, thanks in advance.
Without knowing exactly the error reported, this is a toughy.


I agree. An error message would have helped!!
Here's my guess: you're using reserved keywords for object (field) names.
Either change the names of those fields (recommended) or surround them with
brackets [].
 
JString said:
Do you mean in VBA only, or should the final statement have
apostrophes instead of quotes? The SQL statement I provided is the
return value of my vba code.
Jet should handle quotes as well as apostrophes.
What is the error message (in the event that my suggestion does not help)?
 
The brackets did the trick. Thanks.

Bob Barrows said:
JString said:
Need help with an append query statement that's being run from VBA and
generates an error:

INSERT INTO [Temp6211] (Fields,Operators,Values) VALUES ("PLAINTIFF",
"=", "test")

if anyone can help me, thanks in advance.
Without knowing exactly the error reported, this is a toughy.


I agree. An error message would have helped!!
Here's my guess: you're using reserved keywords for object (field) names.
Either change the names of those fields (recommended) or surround them with
brackets [].


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
 

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

Back
Top