Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


456


no formal distinction between types of events, the following sections categorize events and event
procedures into groups based on the type of object (forms, reports, and so on) that raise the events
within the group.

Tip
Access supports a very, very rich event model. Not many Access developers master every Access event, nor is
there need to. Virtually every Access developer learns and uses the events that are important for the applica-
tions he’s building and then learns other events as he goes. You don’t need to worry about memorizing all
these events — instead, just be aware that Access supports many different types of events and that they’re
there when you need them.


Form event procedures
When you work with forms, you can create event procedures based on events at the form level, the
section level, or the control level. If you attach an event procedure to a form-level event, whenever
the event occurs, the action takes effect against the form as a whole (such as when you move to
another record or leave the form).

To have your form respond to an event, you write an event procedure and attach it to the event
property in the form that recognizes the event. Many properties can be used to trigger event proce-
dures at the form level.

Note
When I refer to form events, I’m talking about events that happen to the form as a whole — not about an event
that can be triggered by a specific control on a form. Form events execute when moving from one record to
another or when a form is being opened or closed. I cover control events in the “Control event procedures”
section, later in this chapter.


Essential form events
Access forms respond to many, many events. You’ll never write code for most of these events
because of their specialized nature. There are, however, some events that you’ll program over and
over again in your Access applications. Table 12.2 lists some of the most fundamental and impor-
tant Access form events. Not coincidentally, these are also the most commonly programmed Access
form events.

In Table 12.2, notice how many events are related to data (Current, BeforeInsert, and so
on). Because Access forms are usually involved in working with data (adding new data, editing,
and so on), Access forms include these events to provide you with a high level of control over data
management.
Free download pdf