Results 1 to 7 of 7
  1. #1
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139

    Database Behavior Resulting from Resetting ID Number

    I reset the ID number in one of my tables that had data. I did this because I created and deleted over 1,000 practice records trying to set up the database. The reset went fine, it did not impact my data and new values have started numbering from 1. My question is, what will happen when the new numbers catch up to the old records. Will Access skip over the numbers already being used or will it continue numbering in sequence and overwrite existing data.

    Thank you!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    You left records in table and reset autonumber seed? I expect this will not go well. I just tested and Access attempts to create next ID in sequence and if it is already in table, triggers 'duplicate values' error.

    However, next time you run Compact & Repair, Access should start numbering from max ID in table. There will be a gap for deleted ID's. So unless you plan to fill in 1000 records before next C&R, you will get gaps anyway. Gaps should be irrelevant to function of this field in db design.

    How did you reset the seed? If table had dependent tables, should have used method for related tables described in https://support.microsoft.com/en-us/...alue-in-access
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,424
    what will happen when the new numbers catch up to the old records. Will Access skip over the numbers already being used or will it continue numbering in sequence and overwrite existing data.
    Neither, you'll get a database error along the lines of 'unable to insert due to key violations'

    If you are going to reset the autonumber, you need to delete all the records, or start the number with a higher value. The autonumber should have no meaning other than to uniquely identify a record, so it should not matter about resetting it

  4. #4
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    I created a backup first in case it did not go well, deleted the relationships, ran the query below.

    I reset it with this query:

    ALTER TABLE [tablename] ALTER COLUMN [fieldname] COUNTER(1,1);

    I will run compact or repair or I could use the query again and reset the number to the next record ID.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Should run C&R periodically anyway, especially after design changes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    Thank you! I'm extremely new to this.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If you are going to reset the autonumber, you need to delete all the records,
    Not sure I would agree with that. IF there are no related records in other tables that need to remain related, I'd remove the index, save and close the table, reopen in design and re-establish the index. Another option would be to import everything into a new db, choosing to import the table definitions only. That will start the seed at 1.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Why is this code resulting in an update?
    By scott0_1 in forum Programming
    Replies: 1
    Last Post: 06-29-2018, 11:34 AM
  2. Split database - unexpected behavior
    By Lynn Cohen in forum Database Design
    Replies: 5
    Last Post: 09-16-2016, 06:53 AM
  3. Replies: 2
    Last Post: 07-29-2015, 01:17 PM
  4. Auto number resetting
    By malix.creatives in forum Sample Databases
    Replies: 0
    Last Post: 02-17-2015, 07:50 AM
  5. DSUM is not resulting
    By azhar2006 in forum Forms
    Replies: 1
    Last Post: 08-16-2014, 05:10 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