By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

autonumber key violation on insert

P: n/a
Hi again.
I'm running Access 97 and in code, using docmd.runsql, I insert new
rows into a table. The destination table's key field is an autonumber.
99% of the time the code works fine but sometimes it won't add the
record/s due to a key violation.

Is this a known bug in Access, is there some workaround?

Thanks
Oliver

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 16 Jun 2005 05:22:13 -0700, or******@hotmail.com wrote:
Hi again.
I'm running Access 97 and in code, using docmd.runsql, I insert new
rows into a table. The destination table's key field is an autonumber.
99% of the time the code works fine but sometimes it won't add the
record/s due to a key violation.

Is this a known bug in Access, is there some workaround?

Thanks
Oliver


It is a bug. On occasion, autonumber sequences can become corrupted. Running
a repair/compact on the database fixes the problems.
Nov 13 '05 #2

P: n/a
On 16 Jun 2005 05:22:13 -0700, or******@hotmail.com wrote:

Check all unique indexes on that table (design view > View > Indexes).
The data to be inserted must be violating one of them. You can write a
query to find the record(s).

-Tom.

Hi again.
I'm running Access 97 and in code, using docmd.runsql, I insert new
rows into a table. The destination table's key field is an autonumber.
99% of the time the code works fine but sometimes it won't add the
record/s due to a key violation.

Is this a known bug in Access, is there some workaround?

Thanks
Oliver


Nov 13 '05 #3

P: n/a
I guess index means primary key? There's only one - the autonumber - I
don't give it a value on the insert (obviously). If it's a bug - which
it seems to be and Steve agrees - then is there some way to minimise it
happening? I need the system to be robust.
Thanks Oliver

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.