Redifine Autonumber Primary Keys

S

shapper

Hello,

I have an access database where I deleted a few records while testing
it.
Is there a way to redifine the autonumber primary key?

My records primary keys are like: 10, 12, 23, 24, 25, etc.

I am using Microsoft Access.

I know this is not necessary but I allways wonder how to redifine the
primary keys on a Microsoft Access database.

Thanks,
Miguel
 
M

Marshall Barton

shapper said:
I have an access database where I deleted a few records while testing
it.
Is there a way to redifine the autonumber primary key?

My records primary keys are like: 10, 12, 23, 24, 25, etc.

I am using Microsoft Access.

I know this is not necessary but I allways wonder how to redifine the
primary keys on a Microsoft Access database.


The whole idea of autonumber primary keys is that they
never, ever, need to be changed.

Changing a natural primary key is enough of a complicated
process, and changing an Autonumber is significantly worse.
 
M

[MVP] S.Clark

I'm not clear on what redefine means. If you want to renumber, then you
would append to the same table, and let a new value be created
automatically. If you want to fill in the gaps for deleted records, you
could append records to the table and stuff the new value.

--
Steve Clark, Access MVP
FMS, Inc
http://www.fmsinc.com/consulting
Professional Access Database Repair
*FREE* Access Tips: http://www.fmsinc.com/free/tips.html
 
J

John Vinson

Hello,

I have an access database where I deleted a few records while testing
it.
Is there a way to redifine the autonumber primary key?

My records primary keys are like: 10, 12, 23, 24, 25, etc.

I am using Microsoft Access.

I know this is not necessary but I allways wonder how to redifine the
primary keys on a Microsoft Access database.

It is not necessary, it is not helpful, and it is not a good idea.

But if you REALLY REALLY want to misuse the Autonumber feature in this
way, create a new, empty table with the same field definitions, and
run an Append query appending all the fields except the autonumber.

Of course if this table is related to any other tables you'll lose the
connection between the data in your current table and the child
tables.

Autonumbers have one purpose ONLY: to be a unique key. They are *not*
intended to be "row numbers", to be sequential, to be free of gaps. If
you want them to be... don't use Autonumbers.

John W. Vinson[MVP]
 

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