Re: SQL Error Help
- From: John Spencer <spencer@xxxxxxxxx>
- Date: Tue, 17 Nov 2009 06:42:24 -0500
What you are missing is that an INSERT statement adds records. Therefore there is no WHERE clause that applies with this syntax.
Also you need the value of lngTrusteeDefendantID inserted into the SQL string and not a reference to the variable - which won't be recognized
Plus you were missing spaces whenever you had a new line.
strSQL = "INSERT INTO taDEFENDANTS(TrusteeDefendantID)" & _
" VALUES(" & lngTrusteeDefendantID & ")"
OR perhaps you want an UPDATE query and not an insert query?
strSQL = "Update taDEFENDANTS(TrusteeDefendantID)" & _
" Set TrusteeDefendantID =" & lngTrusteeDefendantID & " & _
" WHERE DefendantID=" & lngDefendantID
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
RayToddJr wrote:
I have the following SQL:.
strSQL = "INSERT INTO taDEFENDANTS(TrusteeDefendantID)" & _
"VALUES(lngTrusteeDefendantID)" & _
"WHERE DefendantID=" & lngDefendantID & ";"
The Problem:
I get the following error:
Run-time error 3137:
Missing semicolon (;) at end of SQL statement
What am I missing that prevents the code from seeing the semicolon that is there?
Sorry if this is double posted. My system crashed right after I clicked post and never saw the first posted.
- Follow-Ups:
- Re: SQL Error Help
- From: RayToddJr
- Re: SQL Error Help
- References:
- SQL Error Help
- From: RayToddJr
- SQL Error Help
- Prev by Date: making an equation in access
- Next by Date: Re: Change an update query
- Previous by thread: SQL Error Help
- Next by thread: Re: SQL Error Help
- Index(es):
Relevant Pages
|