Results 1 to 10 of 10
  1. #1
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92

    How to recover lost code when Access was shut down via Task Manager

    Hi everyone. Apparently something in my VBA code made Access get caught in an infinite loop, and I couldn't break out of it. I tried Ctrl-Break, Esc, Control-Esc, and just about every other combination I could think of, but nothing worked... so I had to shut down Access via the Task Manager.



    I opened my Access file back up, hoping it would have an auto-recover thing pop up, but it did not. Since I had not saved my database file for a while, I lost all of the code I had written over the previous 30 minutes. I do still have the .laccdb file that was saved before I tried re-opening my Access file, but I just tried to open it via Access and it wouldn't work. I don't even know if this would have the code inside that I am trying to recover. Any ideas how I could recover the code, or is it lost for good?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    When this happens to me, the code is lost. It usually happens to me when I forget to put a .movenext when looping a recordset. It's a bummer.

  3. #3
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    Now that you say that, I think that is exactly what I forgot to put in. UGH. Oh well... time to start rewriting the code, I guess.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Save frequently, certainly before running code after edits.

    Used to work with a Dell desktop computer with keyboard that has a break key that worked really nice to get me out of infinite loop code. Still haven't figured out how to get the break action with my HP Pavilion laptop.
    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
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    mcomp72,

    Not a solution, but rest assured you are not the first to lose code after resorting to Taskmanager to stop/break a looping Access application.
    Backup, backup.....(we all know that... but it happens).
    When you write some vba, save the code from time to time---you may only lose work since the last save.

    After you lose some important vba, your code management practices will change.

    Good luck. Been there.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The .laccdb file just has who was in the Access dB - no code.

    Been there..... for the same reason.... multiple times.

    quick save the code: use Ctl+s

    I now do this about every 4 lines of code......

  7. #7
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Ditto. If you're smart, this only happens to you once. If you're me, then maybe twice
    Now I ALWAYS compile THEN save altered code BEFORE running code that involves loops, and a little less frequently during normal coding, but I still compile and save frequently. I do it in that order on the premise that there's no point in saving it if it doesn't compile anyway..
    Maybe others don't find this humorous, but check out post 4 here elsewhere in this forum. It might help you to remember to save often.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    Other thing to remember is make sure you have a backup before you start work - easy to start coding, saving as you go then realise you've gone down a blind alley, or have thought of a better way and you then want to undo what you have done so far. How you now wish you had commented out the old code......

  9. #9
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Micron View Post
    Ditto. If you're smart, this only happens to you once. If you're me, then maybe twice
    Well...... took me 3 times..


    Also found out the hard way: DO NOT edit code while the code is executing!!!
    Say you added a break point in the code and are stepping through the code line by line. You find an error or you want to add a line or two. If you make changes while the code is executing (the yellow high light is visible), you have a better than average probability of corrupting the VBA project - ie corrupting your dB.

    Go ahead.. ask me how I know.
    I had been editing the code while it was executing for months. ALL backups were at some version of corruption.
    I was able to open the last backup and save the code. Eventually I was able to recover/recreate the dB - took almost 3 weeks. What a PITA!!!

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    If you make changes while the code is executing (the yellow high light is visible), you have a better than average probability of corrupting the VBA project - ie corrupting your dB.
    which reminds me of the other thing to do on a regular basis - decompile. That gets rid of all the rubbish created when making changes that is hidden away

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

Similar Threads

  1. Replies: 5
    Last Post: 05-31-2016, 05:18 PM
  2. Replies: 7
    Last Post: 03-27-2014, 11:47 AM
  3. certain events shut down Access
    By markjkubicki in forum Forms
    Replies: 3
    Last Post: 02-28-2014, 02:37 PM
  4. How to recover lost MDB files passwords?
    By willkett in forum Access
    Replies: 14
    Last Post: 08-17-2012, 01:48 AM
  5. Replies: 5
    Last Post: 01-05-2012, 11:55 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