Re: SQL Error Help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
.



Relevant Pages

  • I/O-Operations
    ... with new findings - here new results of the first trials.. ... The Perl lexer knows whether to expect a term or an operator. ... (Missing semicolon on previous line?) ...
    (perl.beginners)
  • Re: "Array to String Conversion" error when constructing a multi-dimensional array
    ... for a missing semicolon after $x = 0), so I suspect the problem lies ... That is almost certainly where your problem lies. ...
    (comp.lang.php)
  • Re: PHP Parse error
    ... >>The problem was a missing) in the preceding IF statement. ... Usually a missing bracket or semicolon does ... (missing semicolon in the first row) ...
    (comp.lang.php)
  • Re: MSHFLXGD.OCX
    ... > Run-time error `339 ... > `Component "MSHFLXGD.OCX" or one of its dependencies not correctly ... a file is missing or invalid ...
    (microsoft.public.de.german.windowsme)
  • FPDB: Parameter Update Not Working When Non-Param Works
    ... I have an update query ... The first one gives an error message of: ... Database Results Wizard Error ... I do not get any message about a missing parameter (which you usually get if ...
    (microsoft.public.frontpage.client)