Discussion Locked

Access 2000 (autonumber question)

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is there a way to change the value in a autonumber field ?

the autonumber changes everytime you add a new record, but if you are decide to cancel entry in a new record. the autonumber value still increases by one is there anyway to prevent this

7 replies

by donq

I sure wish there was but the answer is no. Microsoft's reasoning is solid in that no record attemt or existing can hide.

I have created a recordset and sorted it the way I want in a query - THEN add a new field set to Autonumber and regenerate the recordset so I have no missing numbers. You must be careful if the Autonumber value is a Key (especially Foreign Key) value if you go about this method of eliminating missing Autonumber values so you don't start pointing to the wrong records. Don Quigg

by alias_ales

Yes - but you must rebuild the table. - It's not a very slick way of keeping your numbers in order - especially if you have alot of data.

A work around I'm using is to use a form that is not bound to the table and commit the autonumber after the user presses an Update or Accept command button. That way if they backout your numbers are not screwed up. You can read the last record and add a number to it if you want to show the user what the number will be...but that has it's drawbacks especially if it will be used by more than one person at a time.

I do not like letting users enter data into tables directly and I have more control when I use a form - where the business rules can be enforced.

by bob sellman

No, you can't change the autonumber value. There are good reasons for that rule.

What are you using the value of the autonumber for? If you absolutely need a sequential number, I would suggest creating a second column that you increment when a new record is added. Index the second column, but keep the autonumber field also.

If you have many users adding records simultaneously, you could still end up skipping numbers even if you don't actually calculate and post the new number until therecord is actually added (which can be impractical, since presumably the user should know the reference number for the new record).

This discussion is closed to new replies.