Cancel button to quit long running function

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?
 
S

Stuart McCall

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.
 
T

The_Contrarian

:

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top