INSERT INTO gets compile error: Expected end of statement.

T

ToppHatt

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

Tom van Stiphout

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
 
T

Tony Chacon

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, ToppHat

You are short on spaces. For example you need one between tblSystem
and (
One way to get this straight is to set a breakpoint at this line, ge
the whole sql statement, paste it into a new query in sql view, an
switch to design view. The parser will complain if there is a synta
error

-Tom
Microsoft Access MVP


Submitted via EggHeadCafe - Software Developer Portal of Choice
Sending SMTP email from within BizTalk Orchestration
http://www.eggheadcafe.com/tutorial...f-1716445b26bc/sending-smtp-email-from-w.aspx
 
T

Tony Chacon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top