vba loop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think I am having a brain fart.

I have a vba loop that is running in a module which also calls a form
that acts like a progress meter. The form is set up to be a pop-up form, so
the form is always on top - which shows the user the progress of the loop
'stuff'. The problem is this.

I want to give the user a way to cancel the operation. I give the user a
cancel button on the pop-up form, but cannot click it to execute it. I
believe this is due to the loop running in the module. How can I run the
loop in the background or be able to click on the cancel button to end the
request. I already have written code where if the user clicks the cancel
button it will end the routine, but cannot figure out what I must do to get
arrow back from the hourglass the click to work.

Thanks,
Jason
 
I think I am having a brain fart.

I have a vba loop that is running in a module which also calls a form
that acts like a progress meter. The form is set up to be a pop-up form, so
the form is always on top - which shows the user the progress of the loop
'stuff'. The problem is this.

I want to give the user a way to cancel the operation. I give the user a
cancel button on the pop-up form, but cannot click it to execute it. I
believe this is due to the loop running in the module. How can I run the
loop in the background or be able to click on the cancel button to end the
request. I already have written code where if the user clicks the cancel
button it will end the routine, but cannot figure out what I must do to get
arrow back from the hourglass the click to work.

Thanks,
Jason

put a flag inside your loop. Call it something like blnContinue and
point it at a checkbox on your form. Then if you uncheck the box, the
loop will stop.

do while blnContinue=True AND [other criteria]
blnContinue = (me.chkContinue = checked)
'process stuff
DoEvents
'update progress meter...
loop
 
Probably good but the poster will probably not be able to use
me.CheckContinue but will need to reference the form and its control in
full. Also

do while blnContinue=TrueAND [other criteria]
blnContinue = (Forms!ProgressForm!chkContinue = checked)
'process stuff
DoEvents
'update progress meter...
loop



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

I think I am having a brain fart.

I have a vba loop that is running in a module which also calls a form
that acts like a progress meter. The form is set up to be a pop-up form,
so
the form is always on top - which shows the user the progress of the loop
'stuff'. The problem is this.

I want to give the user a way to cancel the operation. I give the
user a
cancel button on the pop-up form, but cannot click it to execute it. I
believe this is due to the loop running in the module. How can I run the
loop in the background or be able to click on the cancel button to end
the
request. I already have written code where if the user clicks the cancel
button it will end the routine, but cannot figure out what I must do to
get
arrow back from the hourglass the click to work.

Thanks,
Jason

put a flag inside your loop. Call it something like blnContinue and
point it at a checkbox on your form. Then if you uncheck the box, the
loop will stop.

do while blnContinue=True AND [other criteria]
blnContinue = (me.chkContinue = checked)
'process stuff
DoEvents
'update progress meter...
loop
 
Thanks.
What I forgot was the doEvents command. It has probably been 10 years
ago since I used it ONE time before on another project. Whole problem was to
let the CPU return back to the program so 'other' things may be processed -
like my 'Cancel' button during the loop. And the doEvents command allowed
that to happen....

Jason



I think I am having a brain fart.

I have a vba loop that is running in a module which also calls a form
that acts like a progress meter. The form is set up to be a pop-up form, so
the form is always on top - which shows the user the progress of the loop
'stuff'. The problem is this.

I want to give the user a way to cancel the operation. I give the user a
cancel button on the pop-up form, but cannot click it to execute it. I
believe this is due to the loop running in the module. How can I run the
loop in the background or be able to click on the cancel button to end the
request. I already have written code where if the user clicks the cancel
button it will end the routine, but cannot figure out what I must do to get
arrow back from the hourglass the click to work.

Thanks,
Jason

put a flag inside your loop. Call it something like blnContinue and
point it at a checkbox on your form. Then if you uncheck the box, the
loop will stop.

do while blnContinue=True AND [other criteria]
blnContinue = (me.chkContinue = checked)
'process stuff
DoEvents
'update progress meter...
loop
 
Back
Top