Microsoft Office Tutorials and References
In Depth Information
Understanding UserForm Events
h Deactivate : Occurs when a UserForm is deactivated but doesn’t occur if the form is
h QueryClose : Occurs before a UserForm is unloaded.
h Terminate : Occurs after the UserForm is unloaded.
Often, it‘s critical that you choose the appropriate event for your event-handler
procedure and that you understand the order in which the events occur. Using the Show
method invokes the Initialize and Activate events (in that order). Using the Load
command invokes only the Initialize event. Using the Unload command triggers
the QueryClose and Terminate events (in that order). Using the Hide method
doesn’t trigger either of these events.
The companion CD-ROM contains a workbook (named userform events.xlsm ) that
monitors all these events and displays a message box when an event occurs. If you’re
confused about UserForm events, studying the code in this example should clear things up.
SpinButton events
To help clarify the concept of events, this section takes a close look at the events associated with
a SpinButton control. Some of these events are associated with other controls, and some are
unique to the SpinButton control.
The companion CD-ROM contains a workbook that demonstrates the sequence of
events that occur for a SpinButton and the UserForm that contains it. The workbook,
named spinbutton events.xlsm , contains a series of event-handler routines — one
for each SpinButton and UserForm event. Each of these routines simply displays a
message box that tells you the event that just fired.
Table 13-1 lists all the events for the SpinButton control.
Table 13-1: SpinButton Events
Occurs after the control is changed through the user interface.
Occurs when a drag-and-drop operation is in progress.
Occurs when the user is about to drop or paste data onto the control.
Occurs before the control is changed.
Occurs when the Value property changes.
Occurs before the control actually receives the focus from a control on the
same UserForm.
Search JabSto ::

Custom Search