Results 1 to 9 of 9
  1. #1
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38

    Renumbering Auto-Increment numbers

    Hey guys,



    I have a table with a primary key that is auto-increment. I deleted the first 8 records, which now makes the 9th record the first record in that table.

    Is there an easy way to renumber these records so the previously-9th record now has a primary key value of 1. And the previously-10th record now has a primary key value of 2, and so on?

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    If you need to control the number, you should not use autonumber.
    autonumber doesn't guarantee the continuity.

  3. #3
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38
    Quote Originally Posted by weekend00 View Post
    If you need to control the number, you should not use autonumber.
    autonumber doesn't guarantee the continuity.
    Alright. I'll manually change them to be a number system. I guess I just used auto-number because there were 80+ records and I didn't want to manually number them. Guess being lazy doesn't pay off!

    So I'm assuming that means no, there is no way to reset the numbers.

    P.S. Is there an easier way to change the data type for a field if it's part of a bunch of relationships, WITHOUT destroying those relationships?

  4. #4
    Join Date
    May 2010
    Posts
    339

  5. #5
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    the posted advice is correct. autonumber is a critically important way of assurring a unique row ID is made automatically. but is not the vehicle for display - as you have found out.

    a database table fundamentally has no order. that is an abstraction for humans. a row is a row. what you want to do is put the running order in your display (i.e. form or report) so that no matter when/what records get added/deleted - when you generate a display it will have row numbering. don't do it at the table level.

    so investigate row number in reports/forms - I think this will meet your needs.

    Hope this helps.

  6. #6
    LillMcGill is offline Dagny fan
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Location
    Southern USA
    Posts
    70
    The beauty of autonumber is that it is nonsensical... no one ever needs to change it, no one needs to ever see it. It is true that if you care what value autonumbers are, you aren't using them correctly.

    But if you delete the records and then run compact and repair, that should reset them to 1.

  7. #7
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    just a note: Compact/Repair does not reset the autonumbers as previously suggested.

    and it should not - because these values can be cross referencing foreign keys to other tables.

  8. #8
    LillMcGill is offline Dagny fan
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2010
    Location
    Southern USA
    Posts
    70
    NTC, I respectfully disagree.

    In the original post he said he deleted all the records.

    Compacting a database does indeed reset the autonumbers for EMPTY tables. Please give it a try.

    As I said... "if you delete the records and then run compact and repair, that should reset them to 1 "

  9. #9
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    and I respectfully disagree with your respectful disagreement. His original post was:
    "....And the previously-10th record now has a primary key value of 2, and so on? ..."

    my interpretation is thus that the table isn't empty, and he is attempting to find sequential numbers for display purposes of which compact/repair is not the solution.

    you are right that a totally empty table c/r can reset autonumber - but I don't think that is the topic here.......

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto Increment by 1 Letter
    By Cinquefoil22 in forum Database Design
    Replies: 4
    Last Post: 07-02-2010, 10:35 AM
  2. Auto increment when the form opens
    By Lynn in forum Forms
    Replies: 13
    Last Post: 04-11-2010, 12:49 PM
  3. Replies: 2
    Last Post: 12-08-2009, 01:19 PM
  4. Replies: 2
    Last Post: 09-10-2009, 05:42 AM
  5. Auto-increment for non-100% numerical fields
    By supernoob in forum Access
    Replies: 0
    Last Post: 05-03-2007, 09:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums