Working with databases can be challenging, especially when it comes to managing IDs. An important concept in Microsoft Access is the AutoNumber, which allows you to automatically generate unique IDs for records. In this guide, I will explain how AutoNumbers work and their significance for data organization. Let's go through the various aspects of this topic together.
Key Insights
- AutoNumbers provide automatic counting for records.
- Deleted IDs are not reassigned to maintain data integrity.
- Database repair and compression can reset the ID numbers.
Step-by-Step Guide
1. What are AutoNumbers?
AutoNumbers serve as primary keys in your tables. A primary key is a unique identifier for each record, which facilitates the identification and access to the data. In this lesson, we focus on the automatically generated ID for the driver and the car.

2. Creating Primary Keys
To set a primary key in your database, you must first set the data type to AutoNumber. This is done in the properties of the table where you store your data. For example, each driver receives their own employee number, which is also defined as an AutoNumber.
3. Creating Records
Once you have created your table with the primary key, you can start adding records. Go to the list view of your table to create new entries. The value for the ID is automatically incremented. This way, each new record receives a unique identification.
4. Saving Records
It is important to know that a record is only stored in the database when you enter companion data. For example, you can enter the name, address, and other information about the customer or driver. The AutoNumber is then generated and incremented, as you saw with the first three entries.
5. Deleting Records
If you delete a record, the corresponding ID is not reassigned. This can be confusing because there seem to be "free" ID numbers. If you want to create a new ID after deleting a record, Access will automatically use the next available AutoNumber ID. For example, if ID 2 was deleted, a new record will receive ID 5.
6. Performing Database Repair
To optimize the database, you should occasionally use the "Compact and Repair Database" function. This will save all records again, and all deleted records will be completely removed from the cache. This step not only ensures that the database is free of "dead" records but can also improve performance.

7. Manually Assigning AutoNumbers
It is possible to manually assign AutoNumbers; however, all preceding records must be deleted to reuse an ID. Access does not allow this because the AutoNumber feature stipulates that the numbers are assigned automatically. An attempt to restore an already assigned ID will be rejected.

8. Structuring the Database Correctly
When a record is deleted, it is advisable not to delete it permanently but to set its status to "inactive." This way, the structure of your database remains intact, and it is ensured that all IDs remain unique.
9. Incrementing AutoNumbers
When creating a new record, the AutoNumber feature will use the next available value, regardless of whether a previous record was deleted. You should always keep this in mind when creating and deleting records, as it helps maintain data integrity.
Summary - Unique AutoNumbers in Access: Become a Data Hero
AutoNumbers are an essential tool in Access to ensure that each record receives a unique identification. Understanding how AutoNumbers work is crucial for the effective management of your database. Pay special attention to marking records as inactive rather than deleting them completely to avoid potential ID conflicts.
Frequently Asked Questions
What is an AutoNumber in Access?An AutoNumber is an automatically generated primary key that assigns a unique ID to each record in a table.
Can deleted IDs be reused in Access?No, deleted IDs are not reassigned; Access always assigns the next available ID.
How can I compress my database?You can go to "File" and select the "Compact and Repair Database" option.
What happens when I delete a record?The record is removed, but the ID remains in the system, after which Access automatically increments the ID when new records are created.
Why should I set a record to inactive instead of deleting it?Setting a record to inactive preserves the integrity of the database structure and avoids ID collisions.