SQL Syntax Error

D

DS

I keep getting a Syntax Error on this code, any help appreciated.
Thanks
DS

MONEYSQL = "INSERT INTO SalesDetailsMoney " & _
"SalesDetailsMoney.SalesID, SalesDetailsMoney.LineID, " & _
"SalesDetailsMoney.ItemID, SalesDetailsMoney.QtyPrice,
SalesDetailsMoney.GroupID, " & _
"SELECT SalesDetails.SalesID, SalesDetails.LineID, SalesDetails.ItemID,
" & _
"SalesDetails.Quantity, SalesDetails.GroupID " & _
"FROM SalesDetails " & _
"WHERE SalesDetails.SalesID = Forms!MoveItem!TxtLeftID;"
DoCmd.RunSQL (MONEYSQL)
 
K

Ken Snell \(MVP\)

Yep.... that will give an error. You need to put the field list inside
parentheses:

MONEYSQL = "INSERT INTO SalesDetailsMoney " & _
"(SalesID, LineID, ItemID, QtyPrice, GroupID) " & _
"SELECT SalesDetails.SalesID, SalesDetails.LineID, SalesDetails.ItemID,
" & _
"SalesDetails.Quantity, SalesDetails.GroupID " & _
"FROM SalesDetails " & _
"WHERE SalesDetails.SalesID = Forms!MoveItem!TxtLeftID;"
 
D

DS

Ken said:
Yep.... that will give an error. You need to put the field list inside
parentheses:

MONEYSQL = "INSERT INTO SalesDetailsMoney " & _
"(SalesID, LineID, ItemID, QtyPrice, GroupID) " & _
"SELECT SalesDetails.SalesID, SalesDetails.LineID, SalesDetails.ItemID,
" & _
"SalesDetails.Quantity, SalesDetails.GroupID " & _
"FROM SalesDetails " & _
"WHERE SalesDetails.SalesID = Forms!MoveItem!TxtLeftID;"
Worked Great! Thanks Ken
DS
 

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

Similar Threads

SQL Woes 4
SQL Rowsource 2
SQL Woes 7
Setting Textbox with SQL 2
Loop Question 2
Sum of SQL Statement 1
Loop Returning One Value 6
SQL SYNTAX ERROR 8

Top