Syntax error on Insert Query

J

JC

I'm having problems getting a SQL query to run. This append query doesn't
seem to work, and there is something in the syntax, I think, that is causing
it not to work. Any thoughts?

- Jeff C.

DoCmd.RunSQL ("INSERT INTO tblCustomers (ID, Last_Name, First_Name, Company,
Street_One, Street_Two, City, State, Zip, " & _
"Phone_One, Phone_Two, EMail ) SELECT dbo_Customer.custid,
dbo_Customer.lastname, dbo_Customer.firstname, " & _
"dbo_Customer.company, dbo_Customer.addr, dbo_Customer.addr2,
dbo_Customer.city, dbo_Customer.state, " & _
"dbo_Customer.zipcode, dbo_Customer.phone, dbo_Customer.phone2,
dbo_Customer.email FROM dbo_Customer " & _
"WHERE tblCustomers.ID= '123456';")
 
D

Dirk Goldgar

JC said:
I'm having problems getting a SQL query to run. This append query
doesn't seem to work, and there is something in the syntax, I think,
that is causing it not to work. Any thoughts?

- Jeff C.

DoCmd.RunSQL ("INSERT INTO tblCustomers (ID, Last_Name, First_Name,
Company, Street_One, Street_Two, City, State, Zip, " & _
"Phone_One, Phone_Two, EMail ) SELECT dbo_Customer.custid,
dbo_Customer.lastname, dbo_Customer.firstname, " & _
"dbo_Customer.company, dbo_Customer.addr, dbo_Customer.addr2,
dbo_Customer.city, dbo_Customer.state, " & _
"dbo_Customer.zipcode, dbo_Customer.phone, dbo_Customer.phone2,
dbo_Customer.email FROM dbo_Customer " & _
"WHERE tblCustomers.ID= '123456';")

What is the sense of referring to tblCustomers in your WHERE clause when
that's the table you're inserting into? Shouldn't the WHERE clause be
either

"WHERE dbo_Customer.ID= '123456';")

or, if ID is a numeric field,

"WHERE dbo_Customer.ID= 123456;")

?
 
J

JC

Dirk,

Must've been a senior moment. You are absolutely right. Thanks for the
help.

- Jeff C.
 
Top