Results 1 to 3 of 3
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Resetting Autonumber Field on command

    I want to reset an autonumber field in a table each time it is populated. Step 1 will be to delete the existing contents. Step 2 will be to append the new records where I want the field to be populated starting with 1. One way would be to delete the data then compact and repair, but I don't want to do this. Everry other way I can think of seems like more of a headache. Here's something that might work. I've created an empty table "x" and written this short procedure.



    Code:
    Private Sub cmdNewTable_Click()
        DoCmd.DeleteObject acTable, "xx"
        DoCmd.CopyObject , "xx", acTable, "x"
    End Sub
    Now that I see it I sort of like it, but is there another way to simply reset the autonumber in an existing table?

    Thanks for listening.

    Paul

  2. #2
    drexasaurus's Avatar
    drexasaurus is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Santa Ana, CA
    Posts
    60
    You can reset the table using ADO and a SQL script. Generally you don't want to reseed auto-incrementing fields, but the need can come up and I get tired of reading other posts asking the user to prove a need.
    I don't do it in access myself, but here is an example I found on the SQL script: http://www.utteraccess.com/forum/Res...5#entry2070895
    Here is an example of using a column property to do it by allen browne, although he uses it in order to fix a bug: http://allenbrowne.com/ser-40.html

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thanks for sparing me the lecture (who's got the time) and thanks for the links.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2013, 05:06 PM
  2. AutoNumber Field Format
    By andy-29 in forum Access
    Replies: 5
    Last Post: 11-13-2012, 07:31 PM
  3. Replies: 1
    Last Post: 09-25-2012, 03:58 AM
  4. Autofill field based on autonumber field
    By frevilla in forum Forms
    Replies: 1
    Last Post: 09-11-2009, 02:50 AM
  5. Resetting autonumber when importing
    By bullwinkle55423 in forum Access
    Replies: 3
    Last Post: 06-30-2009, 11:56 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