Results 1 to 5 of 5
  1. #1
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22

    Autonumber increments even though 'cancel' is selected

    I have an autonumber on my table to assign each record a value. When the user hits cancel, the form doesn't save -- which is great -- however, I noticed that when I create a new record, I noticed that the autonumber still incremented. Is there a way to prevent the increment if the user hits cancel and exits the form?



    Example: Record_nmber =40 and user hits cancel; next form the record_nmber is 41. I want it to be 40 since that record number was never created.


    Thanks!

  2. #2
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    I'm not entirely sure if you can, but, it doesn't affect anything if the autonumbers aren't consecutive or go out of order. They will never repeat and that is all that is necessary for their purpose assuming this is your PK.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The short answer is no. Autonumber is assigned to the record before the record is saved and committed. If the record is not committed the number that was assigned to the Autonumber field will not be used again.

    You would have to do a compact and repair to start again with the next available number. For this reason and a few other reasons Autonumber is not used for sequential numbering. Autonumber is for creating Unique values for identifying records.

  4. #4
    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,850

  5. #5
    TAM is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Thanks, everyone. Helpful info!

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

Similar Threads

  1. Replies: 5
    Last Post: 05-27-2014, 02:44 PM
  2. Replies: 4
    Last Post: 11-21-2013, 05:06 PM
  3. Replies: 1
    Last Post: 08-06-2012, 11:29 AM
  4. Replies: 30
    Last Post: 01-16-2012, 05:49 PM
  5. Replies: 9
    Last Post: 06-20-2011, 03:42 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