Results 1 to 8 of 8
  1. #1
    clebergyn is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2012
    Location
    Brazil
    Posts
    48

    Reset autonumber field and delete records?


    I have a table with relationship with another table. Is there a way to reset the autonumber field and delete data without disrupting relationships?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    In general, deleting data can be disruptive. What is resetting the Autonumber going to do for you?

  3. #3
    clebergyn is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2012
    Location
    Brazil
    Posts
    48
    It is a friend who is in need.
    I know that when you create a new table equal to another, the autonumber field is zero, however the relationship crumbles

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If you have a copy of your table, you can import those records into an existing table of the same structure (fields). The trick is not to import records that will violate the No Duplicates rule for the Autonumber field.

    You can create a copy of your original table and not include data, just copy the structure of the table only. Or if you have a copy of the table and it includes temporary records, you can select all of the records and then delete them. The objective is to have no records in the table copy. This will be your table that you can import records into. You can reset the Autonumber to zero by performing a compact and repair when there are no records.

    After the table's Autonumber is reset to zero, you can choose the autonumber start sequence by importing a long integer into that field (Autonumber field). You can use an action query to append a single record into your table. If this single record you import into your table has a value of '1999' and that value is appended to the Autonumber field, the next record created will begin with 2000. You can delete the single imported record. As long as you do not perform a compact and repair, the next record created will be 2000.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I think you are wasting your time worrying what the autonumber number is or trying to reset it.

    Autonumbers fields are not guaranteed to be sequential, nor are they guaranteed to be positive. They are only meant to be unique.
    Autonumbers are NOT meant to have any real world meaning. I've seen where people use autonumbers for Patient IDs or Employee IDs and have the autonumber field visible on a form. This is a very bad practice.

    See:
    http://www.utteraccess.com/wiki/index.php/Autonumbers
    http://www.fmsinc.com/free/newtips/primarykey.asp

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I am not positive what the OP needs. My impression is they need to correct something with their table's Primary Key.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I also think we need to hear from the OP. What data does he/she have? How important is it? How many records are involved? Since this data is related to another table, resetting the autonumber will break the existing relationships.

  8. #8
    clebergyn is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Dec 2012
    Location
    Brazil
    Posts
    48
    OK, I have an idea about this, thanks! thank you all!

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

Similar Threads

  1. Replies: 2
    Last Post: 12-04-2013, 08:09 PM
  2. Replies: 10
    Last Post: 01-29-2013, 08:59 AM
  3. AutoNumber reset
    By Seeletse in forum Access
    Replies: 3
    Last Post: 12-12-2012, 07:14 AM
  4. Reset autonumber in a concatenate field
    By Fish218 in forum Forms
    Replies: 6
    Last Post: 03-13-2012, 11:58 AM
  5. Query to Reset AutoNumber to 1 after full delete
    By saigovind in forum Queries
    Replies: 1
    Last Post: 02-04-2011, 03:43 AM

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