I have a table in an Access database with an autonumber field.
When I delete all the records from the table, the autonumber remembers the last number.
Does A
Access SQL does not have anything like TRUNCATE TABLE
.
You can use an ADO connection to execute a DDL statement which resets the autonumber field's "seed" value. So you could do this with VBA code, and not have to use compact & repair to reset the autonumber.
This example code first deletes all rows from my tblFoo table, and then resets the seed value for the id autonumber field.
Dim strSql As String
strSql = "DELETE FROM tblFoo;"
CurrentProject.Connection.Execute strSql
strSql = "ALTER TABLE tblFoo ALTER COLUMN id COUNTER (1, 1);"
CurrentProject.Connection.Execute strSql