AutoNumber Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have an autonumber field and everytime I enter data, even when I cancel what I've entered, the automatic numbering keeps on going on. How can I go back to number one as all the data entered have been deleted? Please help. Thank you.
 
Marlie said:
Hi Lynn,
I tried to compact the database and yes, it did go back to number one, but
when >I try to enter data again, it is doing the same thing, even if I
cancel what I've >entered, the numbering still continues. What I want is if
I cancel what I've >entered, I want that number for the next record. Please
can someone help. >Thank you.

Hi Lynn,

I don't think you can do that. Once the autonumber field has allocated a
number, it has been used and cannot be re-used if you delete the record. If
you don't want any gaps, you will have to not delete any records. If there
is a record you don't want, you will have to edit it instead of deleting it.

You can howver reset the autonumber fields as follows:
1) Delete the autonumber field.
2) Create a new autonumber field with the same name.

Problem is, if you already have some gaps, you are in a mess.
Also, I don't guarantee that the same numbers will be assigned to the same
records as they were before.
In any case, you should take a copy of your database before trying this.

Alternatively, if you want to keep the same numbers, but don't need an
autonumber:
1) Create a new field, type long integer.
2) Copy the numbers from the autonumber field to the new field.
3) Delete the autonumber field.
4) Rename the new field to the old name of the autonumber field.
If you do this, you will probably need some code added to generate new
numbers in this field for new records. The advantage is that you can ensure
that there are no gaps in the numbers.

David
 
Marlie,
Unfortunately there is no way for that to happen. Once the value has been
used for an autonumber field it is no longer usable. Thus, if you cancel
out, you will get the next number. The AutoNumber datatype was NEVER
designed to provide a gapless sequence. It only provides you with a unique
number for each record.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Marlie said:
Hi Lynn,
I tried to compact the database and yes, it did go back to number one, but
when I try to enter data again, it is doing the same thing, even if I cancel
what I've entered, the numbering still continues. What I want is if I
cancel what I've entered, I want that number for the next record. Please
can someone help. Thank you.
 
Hi Lynn,
I don't think you can do that. Once the autonumber field has allocated a
number, it has been used and cannot be re-used if you delete the record. If
you don't want any gaps, you will have to not delete any records. If there
is a record you don't want, you will have to edit it instead of deleting
it.

David,
Compacting the database will take an Autonumber field back to the next
available number. If all the records are deleted then compacting will cause
the database to start over at 1. If a person has records with Autonumbers of
1 through 1000 and deleted records 200 through 300, then the compact would
not restore those values.
 
Back
Top