Microsoft Office Tutorials and References
In Depth Information
Changing Form Controls with VBA
Figure 4-5:
an event
After you select Code Builder and click OK in the Choose Builder dialog box,
the class module for the form opens. The first and last lines of the procedure
are already typed for you. In this example, the lines look like this in the
Private Sub Payment_Method_AfterUpdate()
End Sub
When you’re writing the procedure, be sure to put all the lines between the
Private Sub and End Sub statements. Listing 4-4 shows the necessary
code. To make things even fancier, the listing code throws in a few DoCmd.
GoToControl statements to position the cursor on the control that the user
is likely to type in next. The statement DoCmd.GoToControl “CCType”, for
example, means “Move the blinking cursor to the control named CCType.”
Listing 4-4: An Event Procedure
Private Sub Payment_Method_AfterUpdate()
‘First, disable controls and hide the label,
‘to create a simple starting point.
Me.CheckNo.Enabled = False
Me.PONumber.Enabled = False
Me.CCType.Enabled = False
Me.CCNumber.Enabled = False
Me.CCExpireMonth.Enabled = False
Me.CCExpireYear.Enabled = False
Search JabSto ::

Custom Search