autonumber fields

  • Thread starter Thread starter Todd Hudson
  • Start date Start date
T

Todd Hudson

I deleted several rows of data and want the next auto number to be 297.
Instead it is 344.

How can I get it to start at 297?

Thanks
 
Copy structure and data from old table into new table.
After that, field(s) with Autonumber will be set to (MaxFound+1).
 
Hi, Todd.
How can I get it to start at 297?

If you need the numbers in this column to be sequential, then you shouldn't
be using an AutoNumber, because they aren't guaranteed to be sequential,
even when they're set to increment by 1. You should use a custom function
to return a sequential number.

That said, assuming that you have 296 records in this table and no numbers
in this column above 297, first make a backup of the database file, turn off
"Track name AutoCorrect," then delete any relationships with this table's
related tables. Rename your table, then make a copy of the structure (no
data) and name this copy the same as the original table. Append the data
from the original table into the new, empty table. Try:

INSERT INTO tblEmptyTable
SELECT *
FROM tblOldTable
ORDER BY ID;

.. . . where tblEmptyTable is the copy of the table that you made which has
been renamed as the original table's name, tblOldTable is the original table
full of records, and ID is the AutoNumber column. When done, reestablish
the relationships with any related tables on the new table. When you've
verified that everything is correct, delete the old table and compact.

When you add a new record, the AutoNumber will be 297.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
Todd said:
I deleted several rows of data and want the next auto number to be
297. Instead it is 344.

How can I get it to start at 297?

Thanks

I suggest you may not want to use Autonumber for that use. Autonumbers are
designed to provide unique numbers. It in not designed to provide numbers
in order and for a number of reasons may not do so. As a result using them
in any application where the user sees the numbers is likely to end up with
confusion.

There are other ways of providing the numbers you want depending on the
particual application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top