DMW logo
tel 01732 833085
tonbridge · kent · UK

Microsoft® Access Autonumber Field
Duplicate-Value Error Message

How to fix a problem of duplicate value errors when inputting a new record into a table with an AutoNumber data type applied to its primary key field.

Last updated on 2020-05-26 by David Wallis.

The Problem

“We have a table that has an AutoNumber primary key field. When we try to input a new record, Access gives a primary key duplicate value error. We have used this type of field before and never had this problem. Can you tell us where we are going wrong?”

Diagnosis of the Problem

The design of your “Invoices” table and your use of the AutoNumber data type for the primary key field is fine. Your table records invoices. The AutoNumber field is named “InvoiceNo”. Your intention is that invoices are numbered sequentially as they are generated.

Your Invoices table is linked to your InvoiceDetails table, which contains line-by-line information about the items covered by an invoice.

On checking the invoice records I note that the last few invoices in the sequence, those numbered 689, 690, 691 and 692, received unusual attention and I believe that this is what has caused your problem.

At some point invoices 690 and 691 were deleted, I understand by someone who had made a mistake and wanted to start them afresh. In order to fill the gaps so that the numbering sequence would remain complete, your database administrator used an Append Query to re-introduce 690 and 691.

I reckon that due to the appending of the numbers 690 and 691 to the AutoNumber field, Access was left with the belief that 692 would be the next number it should autonumber for a new record. As it tried to so it found the attempted new 692 was a duplicate of the 692 still in the table — hence the duplicate value error message.


These are the steps I suggest you take to restore the invoice numbering:

  1. Take a back-up copy of your data
  2. Take a manual record of the information for invoices later than invoice 689 in the invoice table and all other tables that link to it
  3. Remove the link between the Invoices and InvoiceDetails tables that is made between the respective InvoiceNo fields
  4. Delete records for invoices beyond 689 in the Invoices table linked
  5. Compact and Repair the database
  6. Restore the links bewteen the Invoices and InvoiceDetails tables

When you open the database and input a new invoice it should be numbered 690. Rather than trying any Update or Append Queries, you may feel more confident to input the information for invoices 690, 691 and 692 manually, taking care to match input to the information in printouts of these invoices you may have made before the problem arose.

Your Support for dmw TIPS

Please support this website by making a donation to help keep it free of advertising and to help towards cost of time spent adding new content.

To make a contribution by PayPal in GBP (£ sterling) —

To make a contribution by PayPal in USD ($ US) —

If you’d like an invoice to account for your donation, let me know how much you’re donating —


Thanks, in anticipation.

SSL Cerification


DMW Consultancy Ltd does not accept any liability for loss or damage to data to which any techniques, methods or code included in this website are applied. Back up your data; test thoroughly before using on live data.

“I have written a book called ‘In the Wonderland of Numbers’. It’s about a young girl, Neha, who is very poor in mathematics, but in a series of illusory experiences, she becomes a great mathematician.”

Shakuntala Devi