SQL Insert gets syntax error but works in Query !?!

D

David

INSERT INTO tblTicketPriorityHist (TicketID, Priority, When, User) VALUES( 2, '2', #4/22/2004 8:30:15 AM#, 'dcmcspar'

The above statement causes a syntax error when executing VBA but when I paste into a query it runs
I'm using ADO cn.execute statement to run the SQL

Anyone got a clue?
 
K

Ken Snell

You didn't post the VBA code, but I'm guessing that the problem is the
embedded ' characters. If you're using the ' character to delimit the text
string SQL as you build it, then ACCESS thinks your embedded ' characters
are the end/beginning of new strings. Either double up the ' characters ('')
in the string, or use the doublequote " character to delimit the entire text
string.

--
Ken Snell
<MS ACCESS MVP>

David said:
INSERT INTO tblTicketPriorityHist (TicketID, Priority, When, User)
VALUES( 2, '2', #4/22/2004 8:30:15 AM#, 'dcmcspar')
 
P

peg

I think on the ADO - for dates you want to use '4/22/2004 8:30:15 AM' - but
in access queries - it uses the #DATE#

Peggy Yehl

David said:
INSERT INTO tblTicketPriorityHist (TicketID, Priority, When, User)
VALUES( 2, '2', #4/22/2004 8:30:15 AM#, 'dcmcspar')
 

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

Top