Autonumbering

Odessit80

Registered User.
Local time
Today, 11:44
Joined
Sep 10, 2004
Messages
18
Hello,

I need to start autonumbering from a certain number(not from 0). How would I do that in access?

Thank you very much for your help!
 
Don't use auto number fields for anything but field ID's
 
Kak pogoda v Odesse?
If your your table(MyTable) has last ID=50 and you would like to assign id=500 then follow the following technic:
Create query with syntax:

"Insert into MyTable(ID) values(499)"

So next input will take number=500

Udachi.
 
Yeah, I am using autonumbering for IDs only. It is a blank database, but i need to start Invoice numbers not at 0 but at 5000.

Igor, is there any way just to assign something like that in Access without without writing a VB query? I know very little about VB and I would not even know where to insert it. :confused:

K sozhalenie ya seichas ne v Odesse, no v Arizone seichas tozhe neploho :)

Thank you for your help.
 
Last edited:
if I understand well, you can to insert to the table 5000 rows.

For i = 1 To 4999
strsql = "insert into city(cityname) values ('123')"
CurrentDb.Execute strsql
Next

then delete the rows
strsql = "delete * from city"
CurrentDb.Execute strsql

after that the ID number start from 5000
 
Last edited:
If you need the Autonumber to have specific values (a business meaning), then in my opinion, you use an Autonumber for something it isn't intended for. It is only meant to provide a unique number per each record, nothing more. When cancelling a record while typing it, you'll get gaps in the numbers (missing numbers)... how will that go when you're missing Invoice numbers?

Anyway - here's one way of altering an autonumber (think this method requires Jet 4.0/Access 2000+). Just run it in the immediate pane (ctrl+g) using your table and column names.

currentproject.connection.execute "alter mytable alter column InvoiceNo int identity (5000,1)"
 
Thanks guys for your help. Roy, you do have a valid a point about autonumber not being sequential. I guess, I will have to change that.
 

Users who are viewing this thread

Back
Top Bottom