How to Reset or Replace Access AutoNumber Values After Deleting Records
Question details
The user needs to reset or fill gaps in Microsoft Access AutoNumber fields after deleting records.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Deleting records in a database leaves gaps in the AutoNumber sequence, and the user is looking for a way to maintain a continuous, unbroken sequence.
- Observed behavior
- The AutoNumber field skips numbers where previous records were deleted, creating permanent gaps instead of renumbering the remaining records.
Before modifying database fields, understand that AutoNumber fields are designed solely as unique identifiers, not for sequential, gap-free numbering. Changing them in existing records can severely compromise your database integrity.
Use Compact and Repair Database for Recent Deletions
Use this built-in tool if you only deleted the most recent records at the end of the table and want the next new record to resume from the last existing number.
This method is safe because it only resets the auto-increment seed for future records. It will not attempt to fill gaps caused by older records being deleted in the middle of your dataset.
Launch Microsoft Access and open the database containing the table with the deleted records.
Click on the 'Database Tools' tab located in the top ribbon menu.
Click on the 'Compact and Repair Database' button. The database will process and reset the AutoNumber seed to sequentially follow the highest existing ID.

Create a Custom Numbering Field using VBA
If strict sequential numbering without gaps is a business requirement, leave AutoNumber alone and create a separate custom field managed by VBA code.
Looking for a Lightweight and Free Office Suite?
While Microsoft Access is used for complex relational databases, most everyday data tracking, spreadsheets, and documentation can be handled efficiently with WPS Office. It provides a highly compatible, free alternative to Microsoft Office's core applications.
- 1. Visit the WPS Office website: Go to the official WPS Office homepage to access the latest version.
- 2. Download the Installer: Click on 'Free Download' to get the lightweight installation file.
- 3. Install and Run: Follow the on-screen instructions to install WPS Office and open your existing Office files instantly.

Frequently Asked Questions
Why shouldn't I reset AutoNumber values in Access?
AutoNumber fields are designed to be meaningless, unique identifiers that maintain relational database integrity. Changing them can break foreign key relationships with other tables, leading to orphaned records and severe data corruption.
How do I fill gaps in an existing AutoNumber sequence?
You cannot and should not attempt to fill gaps in an AutoNumber field. If your business logic strictly requires a gap-free sequence, you must create a separate custom Number field and use VBA code to manually assign or recalculate the sequence.
Does Compact and Repair fix all AutoNumber gaps?
No. The Compact and Repair utility only resets the next available AutoNumber sequence if you deleted the most recently added records at the very end of the table. It does not renumber existing records or fill historical gaps in the middle of your dataset.




