Unloading a form
Closing dialog boxes is something we hardly think about, because it either happens automatically, or we click on a Cancel button. That is exactly what we need to do with our custom dialog box, instead of having to ungracefully click on the Windows close down button in the top right. We need some coding to facilitate the closing, or unloading, process.
In this recipe, we will be unloading a form from memory.
Getting ready
Make sure that Controls.xlsm
is still open. New Record Entry Form should be visible, and both the Project window and the Properties window should be visible on the left of the VBA Editor.
How to do it…
Let's see how to unload a form:
- In the UserForm window, double-click the Save this Entry button, and then add the
Unload
method as the last line of code:Private Sub cmdSaveEntry_Click() Sheet1.Activate Range("A1").End(xlDown).Offset(1, 0).Select ...