Chapter 12: The Access Event Model . . . . . . . . . . . . . . . . . . . . . . . . . . .
455
of the events most commonly used by Access developers. Most of these events apply to forms and
all the different controls you might add to an Access form.
TABLE 12.1
Events Common to Multiple Object Types
Event Event Type When the Event Is Triggered
Click Mouse event When the user presses and releases (clicks) the left mouse button on an
object
DblClick Mouse event When the user presses and releases (clicks) the left mouse button twice
on an object
MouseDown Mouse event When the user presses the mouse button while the pointer is on an
object
MouseMove Mouse event When the user moves the mouse pointer over an object
MouseUp Mouse event When the user releases a pressed mouse button while the pointer is on
an object
MouseWheel Mouse event When the user spins the mouse wheel
KeyDown Keyboard event When the user presses any key on the keyboard when the object has
focus or when the user uses a SendKeys macro action
KeyUp Keyboard event When the user releases a pressed key or immediately after the user
uses a SendKeys macro action
KeyPress Keyboard event When the user presses and releases a key on an object that has the
focus or when the user uses a SendKeys macro action
Not surprisingly, these events are all associated with the mouse and the keyboard because these are
the user’s primary means of inputting information and giving directions to an application. Not
every object responds to every one of these events, but when an object responds to any of these
events, the event exhibits exactly the same behavior.
Tip
Many developers simply copy and paste VBA code from one event procedure to the same event procedure on
another object. For example, you might want to do some fancy formatting on a text box when the user clicks
into the box. You can copy the code performing the fancy formatting into another control’s Click event pro-
cedure to get the same effect without having to retype the code. Even though you’ll have to fix up the pasted
code with the second text box’s name, it’s much less work than retyping the entire procedure.
Access supports many, many different events. In fact, one of Access’s fundamental strengths is the
wide variety of events available to developers. You can control virtually every aspect of an Access
application’s behavior and data management through event procedures. Although Microsoft makes