-
Hey all....
How can I stop code from executing when a from is show? Like in a commondialog and a msgbox?
Code:
Private Sub Form_Load()
frm2.Visible = True
'other code here...
How could I do it so that code stops executing after frm2 is shown, and continue after its hidden/unloaded?
Sunny
-
cheating?
Why not put it another way round:
Sub Form2_Unload()
'code here
form1.show 'load first form again
End sub
Alternatively, if you didn't wan't this occuring when the form2 closes, what about delaying the code with a timer control?
Hope this helps
Alex
-
Alternativley you could show the Form as modal. This will stop code execution in the calling form, until the new form has been unloaded.
-
Alex,
How would this stop the code from continuing to execute?
After frm2 is show, the code will continue to execute, and will frm2_unload will only execute when it is unloaded, which by then, countless errors would have occurred because it has already gone through most of the program without the needed variables which are obtained from frm2.
Sunny
-
ok good point, this works if it's a 1-2 code line, will give future answers more thought!
Alex
-
This code will show form2 and stop any code below the Loop.
Code:
Private Sub Form_Load()
frm2.Visible = True
Do
DoEvents
Loop
'other code here...
End Sub