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 Error Help



 
 
Thread Tools Display Modes
  #1  
Old November 17th, 2009, 05:48 AM posted to microsoft.public.access.queries
RayToddJr
external usenet poster
 
Posts: 17
Default SQL Error Help

The following is the SQL that I have in my code:

strSQL = "INSERT INTO taDEFENDANTS(TrusteeDefendantID)" & _
"VALUES(lngTrusteeDefendantID)" & _
"WHERE DefendantID=" & lngDefendantID & ";"

I keep getting the following error:

Run-time error 3137:
Missing semicolon ( at end of SQL statement.

What am I not including so that the code 'sees' the semicolon.

Thanks,

Ray.
  #2  
Old November 18th, 2009, 03:04 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default SQL Error Help

When you use an INSERT statement, you would not have a WHERE clause (except
in a subquery). If you are trying to change the value of a record that is
already in the table (e.g. the record where DefendantID = lngDefendantID),
then this should be an UPDATE query. Also, you are missing several spaces in
the SQL statement. You should start each line after the first with a space
(e.g. " WHERE...) .


--
Daryl S


"RayToddJr" wrote:

The following is the SQL that I have in my code:

strSQL = "INSERT INTO taDEFENDANTS(TrusteeDefendantID)" & _
"VALUES(lngTrusteeDefendantID)" & _
"WHERE DefendantID=" & lngDefendantID & ";"

I keep getting the following error:

Run-time error 3137:
Missing semicolon ( at end of SQL statement.

What am I not including so that the code 'sees' the semicolon.

Thanks,

Ray.

 




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 09:23 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.