locked
how to Stop a running VBA code in Access RRS feed

  • Question

  • When I run a VBA code is there a way to stop it?

    My last code entered in a loop and did not stop, I had to quit Access to stop it (not responding) and I lost the code as I haven't save it before.

    thanks

    Monday, December 7, 2020 6:21 PM

All replies

  • Ctrl+Break is the keyboard shortcut for pausing VBA code, but that won't work in a very tight loop.

    Inserting a line

        DoEvents

    in a loop will ensure that you can use Ctrl+Break, but it will slow down code execution slightly.


    Regards, Hans Vogelaar (https://www.eileenslounge.com)

    Monday, December 7, 2020 6:54 PM
  • In addition to Hans's comment, you might open the Task Manager before you start testing. When your Access screen frosts over, it’s easy to kill Access. Of course, you’re saving and compiling often, right?


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Monday, December 7, 2020 9:49 PM
  •  and I lost the code as I haven't save it before.

    Hi Mahatma,

    A very simple and SAVE method is to rightclick on the Access icon on the Taskbar: 

    Then Click the last line:  Close Window (Venster sluiten).

    If your code has been changed, you will be asked to SAVE your modifications.

    Imb.


    • Edited by Imb-hb Monday, December 7, 2020 10:39 PM typo
    Monday, December 7, 2020 10:38 PM