Solved

Renumbering Primary key after delete

Posted on 1998-04-13
5
394 Views
Last Modified: 2008-02-01
Is it possible to renumber the primary key after deleting records so that the primary key field doesn't have missing numbers?
0
Comment
Question by:BoB
5 Comments
 
LVL 27

Accepted Solution

by:
aburr earned 50 total points
ID: 1973758
It cannot be done easily. You can fill in the gaps when you enter new records though. You could also make some new tables with Make Table querries and shift the primary key to a serial numbered field.
0
 
LVL 3

Expert Comment

by:chapie
ID: 1973759
from what I understand supposedly it will start at the lowest possible number for you when you repair/compact, but I haven't seen that myself (have tried, but didn't pay a whole lot of attention to it)

you could change the attributes of the autonumber, from incremental to random (which also doubles the possible ranges because it will now include negatives).

Or you can setup your own type of autonuber procedure provided you only use the data tables via a form, and not directly accessing / adding records via table or query
0
 
LVL 2

Expert Comment

by:marti
ID: 1973760
If your Primary Key is long integer I can send you a sample. Please contact me at konst@sprint.ca
0
 
LVL 27

Expert Comment

by:aburr
ID: 1973761
The primary key does not have to be autonumber. If it is, the best way is to use a make table querry and get the records renumbered.
0
 
LVL 6

Expert Comment

by:devtha
ID: 1973762
Hi,
I am experiencing the same type of problem.
What I understand is you have to reindex the table.
When I add a record to the table it goes in fine..
When I retrieve that same record base on the different criteria I can see that record. When I retrieve the same record base upon the Primary Key it does not show up and gives me my custom message that value not found in the table.
So I assume you have to reindex it in either case.. But how do you do that?
Devtha
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access query expression 6 20
Display label on subreport when NO DATA on subreport 4 22
Binding recordsets to a form 6 23
Dcount help 2 13
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question