Primary key

G

Guest

I created a simple database in an earlier version of Access, and recently
converted it to Access 2000. It was set up to automatically increment the
primary key, and got as high as about 400. Now, in Access 2000 when I try to
add records, the next key it puts in is -32,631, or something like that, then
-32,630, etc. How do I get it to just continue the primary key numbers, and
not start with this huge negative number?
 
D

Douglas J Steele

Autonumber fields exist for the sole purpose of providing a (practically
guaranteed) unique value that can be used for a primary
key. -32631, -32630, -32629 fills that purpose just as well as 400, 401,
403.

Autonumbers are really intended for "human consumption": in fact, it's rare
to show the values to the users. If the value of the number is important to
you, you probably shouldn't be using Autonumbers.

Note that if you replicate the database, the Autonumber will change from
sequential to random numbering.
 
G

Guest

Thanks, Doug. I understand that. The reason I would like it to just
continue with the existing sequence is convenience. I enter new data into
the existing table, and it's less confusing if I can just add to the bottom
of the table, and not have the entries mixed in somewhere. Is that possible?
--
Jack


Douglas J Steele said:
Oops, yes. Thanks, Bruce!
 
B

BruceM

I'll jump back in and say that in general you should really not be entering
data directly into tables. That's what forms are for. You can use
datasheet view of a form if you want to emulate the look of a table. You
can base the form on a query that is sorted as you choose, or you can use
the form's Order By property. In either case the new record will be added
to the bottom as the form appears on the screen. The same thing applies to
a table. If you are making a one-time (or rarely changing) list such as
departments or something of the sort you may decide to just enter the data
directly in a table, but for day-to-day use a form is the best choice. I
would suggest that if you need to maintain a sequential order for the
records you should probably use something like an automatically incrementing
number (for example, the first record would be 0001, the second 0002, and so
forth), or maybe a date or time stamp. For reasons already mentioned,
autonumber is not a good choice.
 

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

Top