Article ID: 287756 - Last Review: June 13, 2007 - Revision: 9.1 AutoNumber field is not reset after you compact an Access database
This article was previously published under Q287756 Moderate: Requires basic macro, coding, and interoperability
skills. This article applies to a Microsoft Access database (.mdb or .accdb) and to a Microsoft Access project (.adp). On This PageSYMPTOMS When you delete the last record or records in a table or in
a form that has an AutoNumber field, and then you compact the database, the
AutoNumber field does not start at the next higher number when you add new
records. CAUSE You have installed Microsoft Jet 4.0 Service Pack 4
(Msjet40.dll version 4.00.2927.4) or later. RESOLUTION Use one of the following two methods to work around this
behavior. Method 1Create a new table and append the existing records to the new table. New records that are added to this table will start with an AutoNumber value of one unless you set the increment value programmatically.Note If you no longer need your records, you can also reset the AutoNumber field by deleting all the records from the table, and then compacting the database. However, if you use this method, you cannot get the deleted records back. To create a new table and append the existing records to the new table in a Microsoft Access database (.mdb), follow these steps:
Method 2You can use the following function in a Microsoft Access database (.mdb) to programmatically reset the seed value of your AutoNumber field. You can add the function to a module, and then run it in the Debug window. Or, you can call the function from a command button or from a macro.Note For this code to run correctly, you must reference both the Microsoft ActiveX Data Objects 2.x and the Microsoft ADO Ext 2.x for DDL and Security Libraries (where 2.x is 2.1 or later.) To do so, click References on the Tools menu in the Visual Basic Editor. Make sure that the Microsoft ActiveX Data Objects 2.x and the Microsoft ADO Ext 2.x for DDL and Security Libraries check boxes are selected. STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. MORE INFORMATIONSteps to reproduce the problem
REFERENCES
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
202121
(http://support.microsoft.com/kb/202121/
)
Cannot change default seed and increment value in UI
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top
