problem with key violation

D

DawnTreader

Hello

i have a form where i want it to drop information into a different table
based on a choice in the combo box. this was working but now it isnt. i am
getting an error of a key violation on the SQL line.

here is the sql:

sql = "INSERT INTO tblRMATracking (ServiceRepId, DateCreated, RMAStatusID)
VALUES (" & ServiceRepId & ", '" & Now() & "', 1)"

now in the table the field DateCreated which records when the record is
created has the property default value of "=Now()". is this "colliding" with
the "& Now() &" in the SQL?

any help appreciated.
 
J

John W. Vinson

Hello

i have a form where i want it to drop information into a different table
based on a choice in the combo box. this was working but now it isnt. i am
getting an error of a key violation on the SQL line.

here is the sql:

sql = "INSERT INTO tblRMATracking (ServiceRepId, DateCreated, RMAStatusID)
VALUES (" & ServiceRepId & ", '" & Now() & "', 1)"

now in the table the field DateCreated which records when the record is
created has the property default value of "=Now()". is this "colliding" with
the "& Now() &" in the SQL?

any help appreciated.

Only if you have a unique index on it. If the table defaults to Now() anyway,
I'd simply leave it out of your Insert statement altogether; if you just
insert the ServiceRepID and RMAStatusID the DateCreated will be filled in by
the default property, you don't need to fill it yourself.

I suspect that the key violation is coming from elsewhere, though! What's the
table's Primary Key? Can you be certain that the value of ServiceRepID in your
code is in fact a valid ServiceRepID, and that 1 is a valid RMAStatusID?
 

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