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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any trick to setting the starting point of Auto-number field? 3

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
0
0
US
Is there a trick to starting an autonumber field at, let's say, 1001 instead of 1.

Steve728
 
Been answered many a time. Just do a search. However, here it is.
Let’s say you want the numbering to begin with a different number other then 1. Let’s say 57. Create your table with NO data and no primary key. Have a field called ID and make the data type Number. Save your table. Select your table, right click and select Copy. Then right click and select Paste. Give it a new table name and select Structure Only. Open up this new table and create one record with ID the starting number one less then the one you want, in this case 56. Close this table. Open the first table and now make the ID field an Autonumber type. Close the table. Create an append query from the second table appending the one record to the first table. Now open the first table and add another record. It will automatically be 57. Delete record number 56.
 
Your post implies that you wish the autonumber to mean something. This can only lead to grief.
 
VBA code:
DoCmd.RunSQL "ALTER TABLE yourTable ALTER COLUMN yourAutoNumber COUNTER(1001,1)"

SQL code:
ALTER TABLE yourTable ALTER COLUMN yourAutoNumber COUNTER(1001,1);

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

Part and Inventory Search

Sponsor

Back
Top