
How to Cancel Execution with Cancel Button?
Form1 = your main form with a long processing routine
Form2 = progress/cancel dialogue.
Create a public property in Form2 called Cancel.
Public Property Get Cancel() As Boolean
Cancel = fblnCancel
End Property
In your cancel button Click event, set the variable to true.
Private Sub cmdCancel_Click()
fblnCancel = True
End Sub
In Form1, use this code in your processing routine:
Private Sub LongProcess()
' The combination of these two commands will simulate a modal dialogue
Form1.Enabled = False ' disable the main form
Form2.Show , Form1 ' show the progress form
' The main routine
Do While Form2.Cancel = False
' Do your processing here
Loop
' Always put things back the way you found them
Unload Form2
Set Form2 = Nothing
Form1.Enabled = True
End Sub
--
John Tabor
http://www.*-*-*.com/ ~jftabor
Note: Anti-spamming suffix of ".nospam" added to header.
-------------------------------------
Quote:
>This method works OK, but it seems like there would be an easier way. Any
>suggestion is much appreciated.