syntax error in sql?

llaman

New Member
Joined
Jul 14, 2004
Messages
37
This returns a syntax error and it seems to match other examples i see in the forum. Any ideas what could be wrong with it?


Sub Update_Invoice(new_key As Integer, company_id As Integer, invoice_date As Date)

Dim SQL As String

SQL = "INSERT INTO " & "Invoice Purchase " & _
"(" & new_key & ", " & customer_id & ", " & new_key & ", " & invoice_date & ", 0) "

DoCmd.RunSQL SQL

End Sub
 
I still have not figured out what could be wrong with the INSERT INTO statement though... any ideas?

SQL = "INSERT INTO Invoice_Purchase (invoice_id, customer_id, item_line, date, ShipID)" & _
" VALUES (" & new_key & ", " & company_id & ", " & new_key & ", #" & invoice_date & "#, 0)"

(assume end of lines are correct)

It responds with a syntax error. I have tried for a long time but I can't figure it out.
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
The 'date' here:
INSERT INTO Invoice_Purchase (invoice_id, customer_id, item_line, date, ShipID)"
is the problem. Date is a reserved word in Access, try changing the name of that field and update the above expression to reflect this change.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top