Form acces during intensive subroutines

Here is my situation.

I have a form that kicks off
an intensive subroutine that loops through some data and does a bunch of inserts into a DB.  During this process, I want to pop open another
form that allows the user to click a cmdbutton to cancel the operation.  I can do the rollback and all that.  My problem is in actually being able to get the cancel form to respond to the users click.  Since the app is responding to the subroutine and doing all of its inserts it seems to hold the form that the routine is in hostage.  I cant do anything else.

I have always had form problems of this type in VB (i.e. when doing something intensive you usually can't move the current form around, minimize it, etc)
and have never really been able to solve them.

Any ideas?
Thanks a bunch.
Who is Participating?
mcriderConnect With a Mentor Commented:
You need to put a DoEvents Statement in your loop... This will yield processor time away from the loop and allow other events to fire...

BE CAREFUL when doing this... make sure you dont fire the same event more than once...

For example, lets say you have a commandbutton that kicks off you loop...

If you dont disable the commandbutton when you start the loop and enable it again when the loop ends, your user could press the commandbutton twice and get the loop going 2 times...

Thanks for the points! Glad I could help!

All Courses

From novice to tech pro — start learning today.