You can execute an Access DDL statement from ADO to reset the autonumber seed value. Here is an example Immediate window session:
strDdl = "ALTER TABLE Dummy ALTER COLUMN ID COUNTER(1, 1);"
CurrentProject.Connection.Execute strDdl
The statement must be executed from ADO. It will fail if you try it with DAO (such as CurrentDb.Execute strDdl
), or from the Access query designer. The example succeeded because CurrentProject.Connection
is an ADO object.
The two values following COUNTER
are seed and increment. So if I wanted the autonumber to start from 1000 and increment by 2, I could use COUNTER(1000, 2)
If the table contains data, the seed value must be greater than the maximum stored value. If the table is empty when you execute the statement, that will not be an issue.