Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


468


are specifically provided for the purpose of controlling the user interface, while the Enter and Exit
events are more “conceptual” in nature and are not often programmed in Access applications.

This small example helps explain, perhaps, why Access supports so many different events. Microsoft
has carefully designed Access to handle different categories of events, such as data or user-interface
tasks. These events provide you with a rich programming environment. You’ll almost always find
exactly the right control, event, or programming trick to get Access to do what you need.

Opening a form with an event procedure
Most applications require multiple forms and reports to accomplish the application’s business
functions. Instead of requiring the users of the application to browse the database container to
determine which forms and reports accomplish which tasks, an application generally provides a
switchboard form to assist users in navigating throughout the application. The switchboard pro-
vides a set of command buttons labeled appropriately to suggest the purpose of the form or report
it opens. Figure 12.6 shows the switchboard for the Collectible Mini Cars application.

FIGURE 12.6

Using a switchboard to navigate through the forms and reports of an application


The Collectible Mini Cars switchboard includes five command buttons. Each command button runs
an event procedure when the button is clicked. The Products button (cmdProducts), for example,
runs the event procedure that opens frmProducts. Figure 12.7 shows the Properties window for
cmdProducts. Figure 12.8 shows the VBA code for the Click event of cmdProducts.
Free download pdf