PDA

View Full Version : Why Doesn't the autonumbers change?



prabhafriend
01-27-2011, 02:09 AM
I am having a table in which I have an autonumber field. But I want to re-apply the autonumber after sorting the data. I cannot do it. Why doesn't the sequence of autonumbers change? I want to know the fundamentals of it. Kindly help.

CreganTur
01-27-2011, 07:10 AM
But I want to re-apply the autonumber after sorting the data.
I have no idea what you mean by this. Please explain.

Autonumber fields are there to allow you an easy way to create a unique identifier for records that do not have easily identifiable unique elements. They're also very useful for creating foreign key relationships, but if handled improperly they are sloppy and can cause a lot of problems. Autonumber is not something that is easy to control because it is meant to be unique. The autonumber itterates every time a record is added. You cannot sort records and then rearrange the autonumber to fit an arbitrary design excepting that you could sort the records in a separate table and then load them into an autonumber table in the exact order you want, but that would take some serious time and effort.

hansup
01-27-2011, 10:55 AM
An autonumber is intended to remain unchanged for the life of the record. If your design includes a need to change assigned autonumbers, change the design. Use a long integer instead of autonumber; then you can re-assign its value as you wish.

GaryB
01-28-2011, 02:03 PM
There is an article about editable autonumbering you might want to look at. I wrote it and in fact have been using it for the last 5 years. This may be a way to do what you want.