SQL INSERT INTO....error message

MikeEller

Registered User.
Local time
Today, 13:16
Joined
Jan 7, 2005
Messages
32
Hi,

I am trying to make the code shown below work....and I get the error message: Syntax error in query. Incomplete query clause.

Here is the code...I cannot figure out why it won't work.

Any ideas?


Dim cpyText As String
Dim sql As String
Dim newName As String

cpyText = List11.Column(0, List11.ListIndex)
fld_lname.SetFocus
newName = fld_lname.Text

sql = "INSERT INTO '" & newName & "' ([perm]) VALUES ('" & cpyText & "')"
DoCmd.RunSQL (sql)

When I hit the debug button on the error dialog box, the highlighted text is the DoCmd.RunSQL (sql). When I hold the cursor over the (sql)...the sql statement reads as I think it should...meaning the variables are replaced with the correct data values.

So what is wrong with the statement? I know it is probably something simple and obvious.

Thanks,
Mike
 
INSERT INTO tblName

also you need a ; at the end of the statement
 
jeremy,

The tblName is the first variable in the statement...that is coming out fine in the debug. Adding the ; at the end inside the ending " did nothing. Outside the ending " gave an error in the code window.
So that is not the problem.

Mike
 

Users who are viewing this thread

Back
Top Bottom