|
In its simplest form, VBA is a glue language, binding an
Access object's event to some action. For
example, the user clicks a command button that triggers the
procedure you will write (Download the sample).
In the sample below, the research area on the main form
is chosen from a drop-down list (an object called the combo box control) while the subform
contains the researcher names in that research area. We can
use the form design view to create the two forms. The main
form is called frmResearch, and the subform is called subfrmName.

Now, we need to add an action so that whenever the
research area is changed via the combo box control, the researcher name
list in the sub form will be re-queried based on the new criterion.
The change of selected items in the combo box control is an event called onAfterUpdate. When the event procedure is invoked, we define a
procedure to execute the form method called Requery (see below).
Private Sub Combo0_AfterUpdate()
Me.subfrmName.Requery
End Sub
In this section, we will review some basic elements in
VBA for MS Access, from starting a simple command button procedure,
through the various actions that procedures can perform, and then the
collections of objects.
|