Avatar of vbnetcoder
vbnetcoder
 asked on

in my VBA code I want to be able to delete all the records from a table and then set the ID back to 1 for the next time records are added to the table. What is the best way to do that?

in my VBA code I want to be able to delete all the records from a table and then set the ID back to 1 for the next time records are added to the table. What is the best way to do that?
Microsoft AccessVBA

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
irudyk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
PatHartman

1. Doing results in bloat.  Access cannot reuse the space that was allocated to the table so when you append new records, they go into newly acquired free space.  The only way to recover the unused space is by compacting the database.
2. Autonumbers have no meaning.  Their sole purpose is to provide a unique identifier for each row in the table.  It doesn't matter whether the ID is 1 or 89043367.
Gustav Brock

It might be simpler just to roll your own row numbering - for example by using my RowNumber function here:

Sequential Rows in Microsoft Access
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck