A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL Syntax



 
 
Thread Tools Display Modes
  #1  
Old June 28th, 2008, 10:20 PM posted to microsoft.public.access.queries
JString
external usenet poster
 
Posts: 90
Default 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  
Old June 28th, 2008, 10:29 PM posted to microsoft.public.access.queries
[email protected]
external usenet poster
 
Posts: 87
Default 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  
Old June 28th, 2008, 10:43 PM posted to microsoft.public.access.queries
JString
external usenet poster
 
Posts: 90
Default 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  
Old June 28th, 2008, 10:45 PM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default 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  
Old June 28th, 2008, 10:55 PM posted to microsoft.public.access.queries
Bob Barrows [MVP]
external usenet poster
 
Posts: 441
Default 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  
Old June 28th, 2008, 10:57 PM posted to microsoft.public.access.queries
JString
external usenet poster
 
Posts: 90
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.