Hi,
I am pretty new to Access so please excuse me if my error is total muppetry.
When running an INSERT INTO query in Access 2007 VBA I keep getting the error "Microsoft Access can't append all the records... due to key violations. I have read a few threads and cannot find the problem.
Here is the code that hangs. It has worked before and now fails after synching across machines.
SQL = "INSERT INTO Fleet ( ModifiedRegion, seatcat, YearEnding, Fleet )" & _
"VALUES ('" & region & "', " & seatcat & ", " & MyYear & ", " & MyFleet & ");"
DoCmd.RunSQL SQL
All of the values are variables and all have something in them and all are of the right data type. I have tried running
The destination table resides in a backend database in the same folder and has the primary key ID that is an autonumber field. No fields 'required' and all text fields allow zero length. I have created a custom index on the fields ModifiedRegion, seatcat and YearEnding. For this index, primary key and unique are set to 'No' and Ignore Nulls is set to 'Yes'. I have tried deleting the key but it makes no difference. The table does not have relationships and referential integrity is not enforced.
Any ideas appreciated.
Thanks
step
I am pretty new to Access so please excuse me if my error is total muppetry.
When running an INSERT INTO query in Access 2007 VBA I keep getting the error "Microsoft Access can't append all the records... due to key violations. I have read a few threads and cannot find the problem.
Here is the code that hangs. It has worked before and now fails after synching across machines.
SQL = "INSERT INTO Fleet ( ModifiedRegion, seatcat, YearEnding, Fleet )" & _
"VALUES ('" & region & "', " & seatcat & ", " & MyYear & ", " & MyFleet & ");"
DoCmd.RunSQL SQL
All of the values are variables and all have something in them and all are of the right data type. I have tried running
The destination table resides in a backend database in the same folder and has the primary key ID that is an autonumber field. No fields 'required' and all text fields allow zero length. I have created a custom index on the fields ModifiedRegion, seatcat and YearEnding. For this index, primary key and unique are set to 'No' and Ignore Nulls is set to 'Yes'. I have tried deleting the key but it makes no difference. The table does not have relationships and referential integrity is not enforced.
Any ideas appreciated.
Thanks
step