Results 1 to 6 of 6
  1. #1
    Jayfaas is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    7

    Autonumber issue


    I recently ran a query for our reports from our database to try to find out what parts I needed to send back, and after running the report, I started removing lines from the query that I knew had already been taken care of. After a while, I realized they were removed from the entire database instead of just the query report(which really sucks). Is there a way I can go back in and manually enter the information back in so I can use the same Autonumber, because we have sent out monthly reports with those numbers being referenced and I would hate for it to come back to us where someone wants to know what happened on ...165 and cant find it because it was removed.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Autonumber keys are not supposed to be known to users. Deleting data should be a rare event. Use filter criteria to 'remove' lines from query. However, the missing ID would be an issue even if it were not an autonumber.

    An INSERT sql action could save record with the deleted autonumber. This will put the autonumber seed out of order until Compact & Repair is run. So do that before adding records by data entry.
    Last edited by June7; 08-29-2014 at 01:40 PM.
    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
    Jayfaas is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    7
    Is that difficult to do? We use the autonumber as a log number to reference the reports. There have been times where I have completed a record and accidentally hit the escape key and it deletes the record(which I think they should fix to add a prompt).

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Something like (example with text, date, number fields):

    CurrentDb.Execute "INSERT INTO tablename(autonumberfieldname, fieldname1, fieldname2, fieldname3) VALUES(165, 'data1', #data2#, data3)"

    Code could capture the Escape key press. Once a record has been initiated, the autonumber value is committed. Canceling the data entry won't recover the number. Ideally, these gaps in autonumber should be irrelevant.
    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.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is some info about Autonumbers & Primary Keys

    Autonumbers--What they are NOT and What They Are
    http://www.utteraccess.com/wiki/index.php/Autonumbers


    Primary Key Tips and Techniques
    http://www.fmsinc.com/free/newtips/primarykey.asp


    Use Autonumbers properly
    http://access.mvps.org/access/general/gen0025.htm

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If this is a split database, be sure to run Compact & Repair on the backend before doing normal data entry.
    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.

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

Similar Threads

  1. CDate and CStr issue with "Invalid Use of Null" Issue
    By excellenthelp in forum Queries
    Replies: 3
    Last Post: 07-25-2014, 01:34 PM
  2. Replies: 4
    Last Post: 11-21-2013, 05:06 PM
  3. Replies: 22
    Last Post: 05-21-2013, 07:54 PM
  4. Using AutoNumber to issue specific numbers
    By capnpat in forum Access
    Replies: 8
    Last Post: 04-13-2011, 03:57 PM
  5. Access DB issue with autonumber
    By cusfirstadmin in forum Forms
    Replies: 1
    Last Post: 12-02-2010, 10:45 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