Hiding

Hides the userform although it is still loaded in memory so you can still access all the control values.


UserForm.Field2.Value = "" 
UserForm.Label1.Caption = "LOADING..."
UserForm.Repaint

If for some reason you would like your userform to disappear immediately while its macro is still executing, use the Hide method at the top of the procedure and follow it with a DoEvents command.
For example the following procedure, the Userform disappears immediately when the button is pressed and then the userform eventually unloads once the code has been executed.


Private Sub CommandButton1_Click() 
   Me.Hide
   DoEvents
   For r = 1 to 10000
''do something
   Next r
   Unload Me
End Sub

Hide the form when you actually press Cancel
Run any cleanup code
Unload the form after the cleanup code has run



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext