INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...Congratulations on a brilliant idea and a great site..."

Geography

Where in the world do Tek-Tips members come from?
ItIsHardToProgram (TechnicalUser)
26 May 06 15:36
Is there a fast way to reset autonumber and reasigns numbers from 1 to x following an order....
mhartman1 (TechnicalUser)
26 May 06 16:26
Hello:

One way would be to simply open up your table in design view and delete the autonumber field, and then re-insert the field once again.

Regards
Mark
ItIsHardToProgram (TechnicalUser)
26 May 06 16:32
I guess that would work... but I was afraid to lose the relations?
ItIsHardToProgram (TechnicalUser)
26 May 06 16:33
Could I maybe add a new autonumber and have it replace the old column ?
ItIsHardToProgram (TechnicalUser)
26 May 06 16:34
I need to stop hitting submit, without finishing, maybe i could update table with another table that contains an auto number field with the number of entry?
Remou (TechnicalUser)
26 May 06 17:20
Quotes from my files.
Reset autonumber
================================================
JeremyNYC (Programmer) 15 Sep 05 14:47
thread705-1122927
Keep in mind, though, that there is no reason to reset the autonumber field.
That number should NEVER be relied upon to present any kind of meaningful data.
Autonumbers are guaranteed (more or less) to be unique. They are NOT guaranteed
to be sequential, so the notion of assigning any significance to them is one
that will lead you down a dangerous path. See my write-up here for a bit more
detail: http://www.abcdataworks.com/id33.htm
- Jeremy

Resetting Autonumber
thread702-1122847
PHV (MIS) 15 Sep 05 5:43
reseting an autonumber field to 1

CurrentDb.Execute "ALTER TABLE yourTable ALTER COLUMN myID COUNTER(1,1)"

Reset Autonumber Field
thread702-1050735

apart from compact and repair

flyover789 (Programmer) 1 May 05 8:09
you don 't have to do the compact/repair thing. you can do it during runtime using the following code:

if your autonumber field (in the code I call it [ID]) is the primary key in your table, use:

Code
Function resetautonumber()
DoCmd.RunSQL "ALTER TABLE yourTable DROP CONSTRAINT [ID];"
DoCmd.RunSQL "ALTER TABLE yourTable DROP COLUMN [ID];"
DoCmd.RunSQL "ALTER TABLE yourTable ADD COLUMN [ID] COUNTER CONSTRAINT [ID] PRIMARY KEY;"
End Function

if it's not the primary key, use:

'Code
Function resetautonumber2()
DoCmd.RunSQL "ALTER TABLE yourTable DROP CONSTRAINT [ID];"
DoCmd.RunSQL "ALTER TABLE yourTable DROP COLUMN [ID];"
DoCmd.RunSQL "ALTER TABLE yourTable ADD COLUMN [ID] COUNTER CONSTRAINT [ID] UNIQUE;"
End Function

if you don't wish to index the ID field at all, use:

'Code
Function resetautonumber3()
DoCmd.RunSQL "ALTER TABLE yourTable DROP COLUMN [ID];"
DoCmd.RunSQL "ALTER TABLE yourTable ADD COLUMN [ID] COUNTER;"
End Function
Golom (Programmer)
27 May 06 11:25
Just a note about this

CODE

"ALTER TABLE yourTable ALTER COLUMN myID COUNTER(1,1)"
It does not affect any numbers that are already in the autonumber column. It just causes the next inserted row to start at "1" (the first parameter) and increment by "1" (the second parameter) thereafter. This is an excellent way to get duplicate autonumbers! If you already have

Anum
 1
 2
 3

Then you run the above ALTER statement and then insert two more rows you will then have

Anum
 1
 2
 3
 1
 2


Probably not what you want.

No! No! You're not thinking ... you're only being logical.  
- Neils Bohr

Eupher (MIS)
27 May 06 23:53
Golom,

Assuming the autonumber is primary key with no duplicates, wouldn't this throw an error?

Ken S.
Golom (Programmer)
28 May 06 11:31
Yes ... and it does.

If the autonumber is not specified as primary and/or unique then Access will insert duplicate numbers in the autonumber column.

No! No! You're not thinking ... you're only being logical.  
- Neils Bohr

ItIsHardToProgram (TechnicalUser)
29 May 06 10:13
Thanks for that elaborate post, and thanks for the links REMOU I understand now why you say it is a dangerous path to go through. The thing is I had the autonumber has a reference for my timesheets, might have to change that.....

Thanks

Start A New Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Posting Policies

LINK TO THIS FORUM!
(Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum)
TITLE: Microsoft: Access Other topics Forum at Tek-Tips
URL: http://www.tek-tips.com/threadminder.cfm?pid=181
DESCRIPTION: Microsoft: Access Other topics technical support forum and mutual help system for computer professionals. Selling and recruiting forbidden.