Syntax Error in Insert Statement

  • Thread starter Thread starter Lory
  • Start date Start date
L

Lory

I am getting a run-time error 3134 "Syntax Error in Insert
Into statement"

Here is my code:

strSQL = "Insert into CurInventory_tbl(Style, Description,
QtyOnHand, Date, UserName) " & _
"SELECT '" & colStyle(intCounter) & "', '" &
txtDescription & _
"', " & colCurQty(intCounter) & ", " & Now() & _
", '" & CurrentUser() & "'"
DoCmd.RunSQL strSQL

I've checked my table and field names to make sure i
spelled them correctly. When I check in the immediate
window to see what is in strSQL it looks fine.

Here's what the immediate window shows:

Insert into CurInventory_tbl(Style, Description,
QtyOnHand, Date, UserName) SELECT 'F3N', 'TKCAP WD', 250,
08/23/04 8:46:00 AM, 'LMaxson'

The only thing I thought might be a problem was if the
date needed quotes around it so I tried it with quotes and
without but am still getting the same error.
 
The date delimiter is #, not ". Try putting #s around the date. Also, I
believe there should be a space between the table name and the (.
 
Ok.

I put # around the date, and I spaced between the table
name and the (. It is still giving me the same error.

Here's how it now looks on the immediate window.

Insert into CurInventory_tbl (Style, Description,
QtyOnHand, Date, UserName) SELECT 'F3N', 'TKCAP WD', 250,
#08/23/04 10:24:08 AM#, 'LMaxson'
 
Lory

Date is a reserved word and is what is giving the error. You can fix this
by Wraping Date in [] Square Brackets like [Date]. Should make it all go
away. However in the REAL fix is to rename the dield Date to OnHandDate or
anythiung else that is not a reserved word.

Ron W
 
Thank you so much Ron.

That fixed it....I should have remembered date was a
reserved word. I will rename the field in my table.

Lory
-----Original Message-----
Lory

Date is a reserved word and is what is giving the error. You can fix this
by Wraping Date in [] Square Brackets like [Date]. Should make it all go
away. However in the REAL fix is to rename the dield Date to OnHandDate or
anythiung else that is not a reserved word.

Ron W
Lory said:
Ok.

I put # around the date, and I spaced between the table
name and the (. It is still giving me the same error.

Here's how it now looks on the immediate window.

Insert into CurInventory_tbl (Style, Description,
QtyOnHand, Date, UserName) SELECT 'F3N', 'TKCAP WD', 250,
#08/23/04 10:24:08 AM#, 'LMaxson'
the
date. Also, I quotes
and


.
 
Back
Top