Closing

Once a userform is displayed using the Show method it remains displayed until it is dismissed, using the Unload statement or it is hidden using the Hide method.
Never Hide your userforms always close them since hiding them will not release the resources.
To close a userform use the Unload statement.


Call UnLoad(frmDisplay) 

When the userform is displayed it remains visible until it is dismissed
When a userform is unloaded its controls are reset to their original values.
If the user's choice must be used later on you need to store the value in a global variable.


Terminate Event

A userform is automatically unloaded by default when the user clicks the close button (cross) in the upper right corner.
This close button has no event of its own.
Clicking the close button will stop execution of the userform and any cleanup instructions will not be executed.
The solution is to place your cleanup instructions inside the Userform_Terminate event handler.
This way both the Cancel and the close button will run the cleanup process.



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