Cancel button to quit long running function

  • Thread starter Thread starter The_Contrarian
  • Start date Start date
T

The_Contrarian

I'm using MS Access 2003.

I've created a form that has a function which polls individual computers in
a loop, adding data as it goes along to the database. The process can take a
long time to complete, and I'd like to have the option to cancel the function
while it's running.

While the function is running, the form doesn't accept any of the various
events (such as pressing buttons). Is there anything I can do so that the
function will check to see if I've pressed a cancel button so that it'll exit?
 
The_Contrarian said:
I'm using MS Access 2003.

I've created a form that has a function which polls individual computers
in
a loop, adding data as it goes along to the database. The process can
take a
long time to complete, and I'd like to have the option to cancel the
function
while it's running.

While the function is running, the form doesn't accept any of the various
events (such as pressing buttons). Is there anything I can do so that the
function will check to see if I've pressed a cancel button so that it'll
exit?

Include the keyword DoEvents somewhere in your loop. I usually place it just
before the end of the loop. This allows windows to process other events such
as your button click.
 
:

Include the keyword DoEvents somewhere in your loop. I usually place it just
before the end of the loop. This allows windows to process other events such
as your button click.

Thank you!
 
Back
Top