Key violation on Append Query


G

Guest

Transaction table has ONE key field...Autonumber called TransID. No other
fields are marked as "No duplicates". I'm inserting some transactions from a
linked spreadsheet. Has worked exactly as written before. SQL looks like this:

INSERT INTO tblTransactions ( PartNbr, TransNbr, LineNbr, Qty,
TransactionType, UserID, SessionID, TransactionDateTime )
SELECT qryNewPOs.strPartNbr, qryNewPOs.[PO No], qryNewPOs.[PO Line],
qryNewPOs.Qty, "P" AS Blah1, "Auto" AS Blah2, "Auto" & Now() AS Blah3, Now()
AS Blah4
FROM qryNewPOs;

Note, no reference to TransID, as this is an autonumber field (Access 2003
with FE/BE...all tables are linked to a backend .mdb)

When I run the query, I get a key violation on all inserted records.

Where do I look for an answer? I tried manually adding a record to the trans
table. It worked, and the TransID field incremented by three or four
(probably due to multiple times I ran the above query and failed....) Still
no joy. I deleted the record I added manually. Still no joy.

I think the engine has lost track of the autonumber sequence. How can I
reset it?
 
Ad

Advertisements

G

Guest

Thanks for looking, but I solved it. Turns out the part number field was in a
relationship and the related table wasn't yet updated. My fault.
 

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