Stop a Procedure from another procedure

A

Ayo

How do you stop a procedure by click another button. I want to be able to
click button2 to stop the procedure being run by button1.

Private Sub button1_Click()
runingProcedure
End Sub

Private Sub button2_Click()
stop runingProcedure
End Sub
 
S

smartin

Ayo said:
How do you stop a procedure by click another button. I want to be able to
click button2 to stop the procedure being run by button1.

Private Sub button1_Click()
runingProcedure
End Sub

Private Sub button2_Click()
stop runingProcedure
End Sub

One idea:

Add a module-level or global variable that will be set in button2_Click.
Add code to button1_Click to check the state of this variable in one or
more places as needed.

It's also a good idea to add DoEvents tactically in the button1_Click
code to make sure the click event on button2 is captured appropriately.

Also... make sure you do any necessary cleanup in button1_Click so it
exits gracefully.
 

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