ToppHat, this may be a bit late for your issue, but it may help others in search of the same problem.
I modified your code to include the following string elements and this worked when I tested it.
Dim strSql As String
strSql = "INSERT INTO tblSystems([System_ID], [SerialNumber]) " _
& " VALUES('" & strIDnum & "'," & "'" & strSNnum& & "');"
DoCmd.RunSQL strSql
MsgBox ("New record added")
ToppHat wrote:
INSERT INTO gets compile error: Expected end of statement.
10-Mar-09
I'm just trying to add a new record in a table consisting of two fields
System_ID and SerialNumber. My SQL statement is as follows:
DoCmd.RunSQL "INSERT INTO tblSystems(System_ID, SerialNumber) VALUES(" &
strIDnum & ", " & strSNnum& ")"
This gives me an Expected end of statement compile error. I've tried it
several other ways and get the same error.
Previous Posts In This Thread:
INSERT INTO gets compile error: Expected end of statement.
I'm just trying to add a new record in a table consisting of two fields
System_ID and SerialNumber. My SQL statement is as follows:
DoCmd.RunSQL "INSERT INTO tblSystems(System_ID, SerialNumber) VALUES(" &
strIDnum & ", " & strSNnum& ")"
This gives me an Expected end of statement compile error. I've tried it
several other ways and get the same error.
Re: INSERT INTO gets compile error: Expected end of statement.
On Tue, 10 Mar 2009 13:59:01 -0700, ToppHatt
You are short on spaces. For example you need one between tblSystems
and (.
One way to get this straight is to set a breakpoint at this line, get
the whole sql statement, paste it into a new query in sql view, and
switch to design view. The parser will complain if there is a syntax
error.
-Tom.
Microsoft Access MVP
Your code, now modified to run syntactically correct in Access SQL
ToppHat, this may be a bit late for your issue, but it may help others in search of the same problem.
I modified your code to include the following string elements and this worked when I tested it.
Dim strSql As String
strSql = "INSERT INTO tblSystems([System_ID], [SerialNumber]) " _
& " VALUES('" & strIDnum & "'," & "'" & strSNnum& & "');"
DoCmd.RunSQL strSql
MsgBox ("New record added")
Submitted via EggHeadCafe - Software Developer Portal of Choice
More Fun with Fluent NHibernate Automapping
http://www.eggheadcafe.com/tutorial...9-81ee42171b00/more-fun-with-fluent-nhib.aspx