jwandmrsquared
asked on
Key violation for appending a record
I have a macro that is trying to execute an append query to a table with an autonumbered ID field (which is my key field) but it keeps failing. I have all sorts of other append queries to the same table with no issues, so I am completely baffled.
The way I have this structured is that I choose records from my table (tbl_prepare_financials) and then attempt to duplicate those records. I am NOT appending the key field as it is my assumption that the autonumbering will occur when the records are appended. Is this wrong thinking? I even tried making the select activity ONE query, and then the appned query is based on the select query, but still keep getting 7 key violations. If I "Un-key" the autonumber field, it works but then creates duplicate IDs.
Any suggestions?
The way I have this structured is that I choose records from my table (tbl_prepare_financials) and then attempt to duplicate those records. I am NOT appending the key field as it is my assumption that the autonumbering will occur when the records are appended. Is this wrong thinking? I even tried making the select activity ONE query, and then the appned query is based on the select query, but still keep getting 7 key violations. If I "Un-key" the autonumber field, it works but then creates duplicate IDs.
Any suggestions?
ASKER
The SQL for the second-query:
INSERT INTO tbl_Finance_prepare_budget s_forecast s ( [Finance Contract ID], [Finance Tool Type], [Date of Item], Current_Active, [Effective Month], [Effective Year], Cost, [Forecast Type], Notes, [GA Code], TimeDateChanged, PersonwhoChanged, CashWeek, CashStatus, Check_date, PROD_ID, Total_type, Subtype, pmt_id )
SELECT qry_upd_cash_frcst_upd_sum _line_prty r_step0.[F inance Contract ID], qry_upd_cash_frcst_upd_sum _line_prty r_step0.[F inance Tool Type], qry_upd_cash_frcst_upd_sum _line_prty r_step0.[D ate of Item], qry_upd_cash_frcst_upd_sum _line_prty r_step0.Cu rrent_Acti ve, qry_upd_cash_frcst_upd_sum _line_prty r_step0.[E ffective Month], qry_upd_cash_frcst_upd_sum _line_prty r_step0.[E ffective Year], qry_upd_cash_frcst_upd_sum _line_prty r_step0.Co st, qry_upd_cash_frcst_upd_sum _line_prty r_step0.[F orecast Type], qry_upd_cash_frcst_upd_sum _line_prty r_step0.No tes, qry_upd_cash_frcst_upd_sum _line_prty r_step0.[G A Code], qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ex pr3, qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ex pr4, qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ca shWeek, qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ca shStatus, qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ch eck_date, qry_upd_cash_frcst_upd_sum _line_prty r_step0.PR OD_ID, qry_upd_cash_frcst_upd_sum _line_prty r_step0.To tal_type, qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ex pr1, qry_upd_cash_frcst_upd_sum _line_prty r_step0.Ex pr2
FROM qry_upd_cash_frcst_upd_sum _line_prty r_step0;
I have verified field types on all of the above; what is NOT being appended is the ID field (the indexed/no duplicates one) as I thought the system would fill those in for me since it is an autonumber field.
INSERT INTO tbl_Finance_prepare_budget
SELECT qry_upd_cash_frcst_upd_sum
FROM qry_upd_cash_frcst_upd_sum
I have verified field types on all of the above; what is NOT being appended is the ID field (the indexed/no duplicates one) as I thought the system would fill those in for me since it is an autonumber field.
ASKER
OH, and I checked all other fields...none are required and all that are indexed are "duplicates OK"
"what is NOT being appended is the ID field (the indexed/no duplicates one) as I thought the system would fill those in for me since it is an autonumber field."
Yes ... the system will do that. So, you are saying that field is NOT in the query above? What is Finance Contract ID ?
mx
Yes ... the system will do that. So, you are saying that field is NOT in the query above? What is Finance Contract ID ?
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Compact and Repair can't hurt, may work, but it's a long shot.
Exactly. Can't Hurt.
mx
mx
Compact and repair is the usual route to fix problems with autonumber seeds.
ASKER
DGMG comment identified the problem perfectly, and compact/repair fixed it. Once again, I am kept from many moments of frustration thanks to the guys on this site!!!
Long Live Compact & Repair, DeCompile and DAO !
mx
mx
Let's hope you find the culprit.
No. Do you have any other Unique Indexes that you have created on one or more fields - or a multi-field index?
Any required fields ?
mx