Error (The changes you requested to the table were not successful) when you insert a new record in a table – Microsoft 365 Apps

Microsoft Technical Article






Resolving Autonumber Seeding Errors in Microsoft Access

Troubleshooting Duplicate Value Errors in Microsoft Access Autonumber Fields

1. Overview

🚀 Database administrators and IT support specialists may encounter a specific friction point in Microsoft Access where users are unable to append new records to a table. Even when the data being entered appears unique, Access returns a “Duplicate Value” error (specifically related to indexes, primary keys, or relationships). This phenomenon typically occurs in tables utilizing an Autonumber field for primary key generation. The underlying cause is not necessarily a duplicate entry in the visible data, but rather a desynchronization of the internal seed value that tracks the next available integer for that column.

📋 This issue affects a wide range of versions, including Access for Microsoft 365, and standalone versions from Access 2019 back to Access 2000. When the internal counter (seed) falls behind the actual maximum value existing in the table, Access attempts to assign an ID that is already in use, triggering a validation failure.

2. Key Technical Details

⚙️ The Root Cause: The Autonumber seed can become “incorrectly seeded” due to manual record deletions, bulk append queries where IDs were explicitly defined, or minor database corruption. To resolve this, the internal counter must be manually aligned with the current maximum value in the dataset.

🛠️ Method 1: Standard Maintenance (Compact and Repair)
The first line of defense is the built-in maintenance utility. This process reorganizes the database file on disk and often resets the Autonumber metadata.

  • Launch Microsoft Access and open the affected database.
  • Navigate to the Database Tools tab on the ribbon.
  • Select Compact and Repair Database within the Tools group.

💻 Method 2: SQL Data Definition Language (DDL) Query
If maintenance fails, you can force the counter to a specific value using an ALTER TABLE statement.

  • Open the back-end database containing the table.
  • Create a new query in SQL View.
  • Execute the following syntax:

    ALTER TABLE TableName ALTER COLUMN AutoNumFieldName COUNTER(iMaxID, 1);
  • Note: Replace TableName and AutoNumFieldName with your specific schema names. iMaxID should be the current highest value in the table plus one.

🖥️ Method 3: Automation via VBA
For a more dynamic approach, IT Admins can use a Visual Basic for Applications (VBA) script to calculate the highest ID and reset the counter programmatically.

Sub ResetAuto()
  Dim iMaxID As Long
  Dim sqlFixID As String
  ' Identify the next logical ID
  iMaxID = DMax("<AutonumberFieldName>", "<TableName>") + 1
  ' Construct the DDL statement
  sqlFixID = "ALTER TABLE <TableName> ALTER COLUMN <AutonumberFieldName> COUNTER(" & iMaxID & ",1)"
  ' Execute the fix
  DoCmd.RunSQL sqlFixID
End Sub
    

🧪 How to Reproduce the Behavior:
You can simulate this error by creating a table with an Autonumber PK, adding several records, and then using an INSERT INTO query to manually inject a record with an ID that has already been “passed” or “skipped” by the counter. When the Autonumber eventually reaches that manually inserted value, the conflict occurs.

3. Impact

⚠️ Operational Downtime: This error effectively halts all data entry for the affected table. In multi-user environments or applications with front-end forms, this can lead to application crashes or “Write Conflict” errors that confuse end-users.

🛡️ Data Integrity: While the data itself is rarely corrupted by this issue, the inability to log new transactions or records can lead to data gaps. Admins should view this error as a signal to perform a wider audit of database health and ensure that manual ID assignments via append queries are handled with strict oversight to prevent future seed desynchronization.


Read the full article on Microsoft.com