If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
SQL Syntax
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. |
#2
|
|||
|
|||
SQL Syntax
On Jun 28, 2:20*pm, JString wrote:
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. |
#3
|
|||
|
|||
SQL Syntax
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 " wrote: On Jun 28, 2:20 pm, JString wrote: 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. |
#4
|
|||
|
|||
SQL Syntax
JString wrote:
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" |
#5
|
|||
|
|||
SQL Syntax
JString wrote:
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)? -- 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" |
#6
|
|||
|
|||
SQL Syntax
The brackets did the trick. Thanks.
"Bob Barrows [MVP]" wrote: JString wrote: 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" |
Thread Tools | |
Display Modes | |
|
|