Results 1 to 15 of 15
  1. #1
    HvitrEbrithil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    10

    Accidentally deleted an autonumber# record, now missing a number

    Like the title said, I accidentally deleted a record from my table, now the number is missing, and I can't find a way to get it back. I might be a perfectionist, but I really want the number list to be complete, and not missing any numbers. Any way to fix this?


    Example of the problem:
    Click image for larger version. 

Name:	Capture 2.PNG 
Views:	22 
Size:	11.8 KB 
ID:	12155

    Thanks in advance

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    You could try deleting any records >172. Then Compact and Repair. Then close the db and re-open it.
    However, IMHO this is a pointless exercise as number used in the Auto-Number field has no meaning. It is just a unique identifier for each record.
    Numbers will go missing anyway. If you start to enter a new record and then press the Esc key to abort that entry, the number that it would have used will be lost.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    HvitrEbrithil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    10
    I see.. Yeah I know it's pointless in a way, but I'm also using this as a referance to the episode-number in my list, and it will get messed up in the future for all episodes after season 8. I could add a new column that numbers them one extra time, but it seems unnecessary. Thanks for the help, it helped me understand the autnumber function better!

  4. #4
    HvitrEbrithil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    10
    Tried the method you suggested with compact and repair, worked like a charm! Thanks a lot Now my OCD can rest carelessly

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by HvitrEbrithil View Post
    I see.. Yeah I know it's pointless in a way, but I'm also using this as a referance to the episode-number in my list, and it will get messed up in the future for all episodes after season 8. I could add a new column that numbers them one extra time, but it seems unnecessary. Thanks for the help, it helped me understand the autnumber function better!
    I would strongly advise against using the Auto-Number for anything other than as a unique identifier, as I said earlier, for the reason I also stated then.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    Now my OCD can rest carelessly
    Until the next time you delete a record or Autonumber randomly throws in an out of sequence number. Autonumber is not guaranteed to be sequential, or even positive for that matter, only unique.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

  8. #8
    HvitrEbrithil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    10
    @Bob Fitz

    I see now that it's not a very clever way to go... Hmm, I will consider adding another field with the incremental number, but I'm not sure yet. I find it lacking in aesthetics to have to nearly similar fields.

    @Beetle

    Point taken. I guess I'll live and learn! At least for future tables I know what to do and not to do with autonumbers!

    @ssanfu

    Thanks, the links actually explained a lot for me, and why I shouldn't use the autonumbers for the purpose I am currently using them for.

  9. #9
    DepricatedZero's Avatar
    DepricatedZero is offline Cthulhu Fhtagn!
    Windows 8 Access 2007
    Join Date
    Apr 2013
    Location
    Cincinnati
    Posts
    65
    Quote Originally Posted by Beetle View Post
    Until the next time you delete a record or Autonumber randomly throws in an out of sequence number. Autonumber is not guaranteed to be sequential, or even positive for that matter, only unique.
    fml really? I've got a couple functions that do a quick dirty >0 check on the autonumbered ID. Guess I'll have to get on fixing that. THANK YOU! Hahaha, did NOT know it would throw negatives randomly, I thought it always counted up sequentially

  10. #10
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    I thought it always counted up sequentially
    I usually does, but you cannot guarantee that it will always do that. It will on occasion spit out a number that doesn't follow the sequence or could even be negative.

  11. #11
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    I agree with just about everything everyone here said about autonumbers. If at all possible, don't use them as anything other than their intended purpose as a unique ID (that's not necessarily consecutive, contiguous, or positive).

    That said, If you DO use autonumber fields and need to change their value, you can do so with these Functions. Just be EXTREMELY CAREFUL! Screwing up an autonumber field can make your database unusable!

  12. #12
    HvitrEbrithil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    10
    If I were to use a normal number-field to count upwards for each new entry, is it possible to make access do this for me? Just like the autnumbers?

  13. #13
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    Yes, but as we discussed in your other thread about toggling Yes/No fields, this would be done at the form level (damn! there's that form thing again ). The more you get into your application, the more you'll realize that you need to use forms for data entry. Tables are for storage of raw data only. They are not designed for data entry/manipulation, that's what forms are for.

  14. #14
    HvitrEbrithil is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    10
    Damnit, it looks like I'll have to surrender soon.. Thanks a lot for all of your feedback, people! You'll probably see more questions from me in the future haha

  15. #15
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    It could be done at the Query level, but that's essentially the same as the Form level.

    Code:
    SELECT MAX([MyField])+1 AS [MyNextNumber] FROM MyTable;
    Or you could use *shudder* the DMax() Function. It would work in Queries, Forms, Reports, VBA code, etc.

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

Similar Threads

  1. Replies: 19
    Last Post: 12-21-2012, 06:57 AM
  2. Number generator without Autonumber?
    By Megood in forum Programming
    Replies: 7
    Last Post: 07-19-2012, 08:02 PM
  3. delete query produce #deleted in all deleted values
    By learning_graccess in forum Queries
    Replies: 2
    Last Post: 03-31-2012, 07:20 AM
  4. record deleted
    By akram in forum Access
    Replies: 12
    Last Post: 03-11-2011, 09:23 PM
  5. Find Missing Number in Sequence per Record
    By escuro19 in forum Programming
    Replies: 1
    Last Post: 11-10-2009, 03:15 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