The event handler is pre-determined by the name of the control.
Event handlers procedures must be placed in the corresponding userform module.

ActivateOccurs when the userform is displayed or reactivated.
This event will only fire:
if the userform is visible. (A userform loaded with the Load statement is not visible until you use the Show method)
and when you switch between userforms.
This event will NOT fire:
when you switch between the application and a modeless userform.
AddControlOccurs when a control is added to the userform at run-time.
BeforeDragOverOccurs when a drag and drop operation is in progress while the mouse pointer is over the userform.
BeforeDropOrPasteOccurs when the left mouse button is released and data is dropped and pasted ?
ClickOccurs when the left mouse button is clicked when over the userform. This does not fire when you click on a control on the userform.
DblClickOccurs when the left mouse button is double clicked when over the userform.
DeactivateOccurs when the userform loses focus because a subform is displayed.
InitializeOccurs when the userform is loaded into memory, this is before the userform is displayed.
KeyDownOccurs when any key is pressed while the userform is displayed.
KeyPressOccurs when an ANSI key is presseed while the userform is displayed.
KeyUpOccurs when any key is released while the userform is displayed.
LayoutOccurs when the size of a userform is changed at run-time.
MouseDownOccurs when a mouse button is pressed ??
MouseMoveOccurs when the mouse pointer is moved over the userform at run time.
QueryCloseOccurs before a userform is closed or unloaded.
RemoveControlOccurs when a control is removed from the userform at run-time.
ResizeOccurs when a userform is resized
ScrollOccurs when the userform is scrolled ?
TerminateOccurs when a userform is removed from memory as part of the clean up task
ZoomOccurs when the userform is zoomed ???

Sub Userform_Initialise 

End Sub

Setting Focus to a particular control

This cannot be done in the Load event and must be done in the Activate event


The Activate and Deactivate events only occur when the focus is moved within the application. Moving the focus to another application will not trigger these events.
The Initialise event is typically used to prepare the userform. Controls can be populated and given values, even moved or resize.
When a userform is closed this event procedure is fired. It is possible to set the Cancel property to True in this procedure to prevent the userform from being closed.
The terminate event is not triggered if your application executes the End statement while the userform is loaded.


This event is fired when a userform object is created
This is always the first event that a userform calls

Dim oForm As Userform1 
Set oForm = New Userform


This event is fired every time the userform becomes the active window

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