Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you get an autonum field to start at 1

Status
Not open for further replies.

colezpapa

Programmer
Feb 26, 2007
86
US
I am starting a new app, and I copied over a table from an existing app, Using an autonum field, how can I get it to reset to 1.
 
GOt it....I deleted the field, then re-entered it. Renumbering from 1.
 
If the number has some significant meaning to you, or you want them to always be consecutive, you might want to use something other than autonumber.

For example, if you delete the last record, then create a new record, the new record will not "re-use" the number from the deleted record. So you could end up with a sequence of records with "gaps", e.g. 1, 2, 4, 7, 8, 10 ,....

Maybe that doesn't matter to you, but since you want it to start at 1 it seems the number has some significance to you, and I thought you should be aware of autonumber's behaviour. What it is really meant for is simply to create a unique number - it's not designed to ensure the numbers are in any type of sequence (other than always getting bigger).

 
If you want to do it by code:
DoCmd.RunSQL "ALTER TABLE yourTable ALTER COLUMN yourAutoNum COUNTER(1,1)"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top