Is the a way for a user to abort code?

Daveyk01

Registered User.
Local time
Today, 09:03
Joined
Jul 3, 2007
Messages
144
I have a VBA/Database program that aquires data from an instrument via the serial port while controlling a function of that instrument. The program will control the instrument, take a reading, control it, take a reading until it gets a satistfactory result.

It works great unless the user messes up and does something with the instrument during the process or disconnects a signal source to the instrument, or just plain bumps something.

My program will continue to adjust the instrument and take readings past a point that it knows to stop. You can see the instrument continue to change on its screen and even my form seems to have recovered. But the code is still operating in the background!

If I bring up the code module and click on the "STOP" button on the second row tool bar, the code stops and I can manually restart the test.

Is there a button I can put on my form that can allow the user to stop the code module from running? What VBA command can stop code running in a loop?

Thanks much.
 
How about testing for the Escape key in your loop?
 
How about testing for the Escape key in your loop?

There will be a lot of code locations (funcrions/subs/etc) to test for the <ESC> key. I was hoping there could be a command that simulates the square vcr RESET/STOP button in the VBA Code Edit/developement environment.
 

Users who are viewing this thread

Back
Top Bottom