[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1436
  • Last Modified:

halt access macro

I have a macro in Access that has about a HUNDRED steps. These steps are mostly "OpenQuery" commands. I would like to know how to stop/halt the macro in the middle of it. As far as I can tell, if I decide I want to stop the macro before it is finished I have to
KILL  the Access task itself! When the macro is running no menu item or anything else is selectable. I tried CTRL-BREAK and SHIFT-F5 but they didn't work. I know I can single step through the macro but with over a hundred steps in the macro, this is simply not an option.
HOW can I stop execution of macro without having to kill Access itself ?
0
massar
Asked:
massar
1 Solution
 
ChrisLewisCommented:
First of all, CTRL-Break DOES work, but you're probably hitting it while the queries are running, and its not stopping the macro correctly.  For more control, try these - User interaction:Create a function that brings up a msgbox with yes/no buttons, and return true/false based off the buttons.  Every 5 or 10 lines in your macro, add a line that stops the macro with the condition set to the function.  If you want to stop the macro, you just answer the dialog.  The problem with this is that you have to answer No if you want to continue, and you probably could achive the same results by spliting the macro up.No user interaction:First line of your macro, call a function that creates a junk file in your temp directory.Next, create a function that finds the temp file (using DIR$), and returns true if it exists.  Set the condition on every line in the macro (except the first) to the find function.  If you want to stop the macro, you just delete the file in filemanager/explorer.Try the Ctrl-Break again - it should work!
0
 
massarAuthor Commented:
I tried CTRL-BREAK again and it does appear to work. What was happening before is that before a query was run I would get a msg box asking me whether I wanted to update/delete/create table etc... I would
hit CTRL-BREAK at this point and expected the msg box to go away and the macro to stop but it wouldn't so I would kill Access. This time I hit CTRL-BREAK then answered no to the question and got the macro step dialog box with the halt/continue/step button and I just clicked on halt.
I hope this is the way it should work.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now