I have a INSERT INTO ... SELECT
statement that copies data from one table to another.
The thing though is, the AutoNumber column value in the second table started from the last number in the first one.
Meaning the count of first table is 2000, then, the second table started from 2001.
Using an Access database, how to reset this value?
You can execute an Access DDL statement from ADO to reset the autonumber seed value. Here is an example Immediate window session:
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 becauseCurrentProject.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 useCOUNTER(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.