Microsoft Office Tutorials and References
In Depth Information
Understanding UserForm Events
Click the drop-down list in the upper-right corner of the module window, and you’ll see a
complete list of events for the control.
Figure 13-12 shows the list of events for a CheckBox control.
Figure 13-12: The event list for a CheckBox control.
Select an event from the list, and the VBE will create an empty event-handler procedure
To find out specific details about an event, consult the Help system. The Help system
also lists the events available for each control. When you locate an event for an object,
make sure that the Help system table of contents is displayed. Then you can see a list
of all other events for the object.
Event-handler procedures incorporate the name of the object in the procedure’s name.
Therefore, if you change the name of a control, you’ll also need to make the
appropriate changes to the control’s event-handler procedure(s). The name changes aren’t
performed automatically! To make things easy on yourself, it’s a good idea to provide
names for your controls before you begin creating event-handler procedures.
Several events are associated with showing and unloading a UserForm:
h Initialize : Occurs before a UserForm is loaded or shown but doesn’t occur if the
UserForm was previously hidden.