Microsoft Office Tutorials and References
In Depth Information
14.6.2.2 Activate button
TabIndex
0
We should also note that, in general, there are two places in which a control property can be set: in
the Properties window at design time or using code during run time. Some properties should be (or
must be) set at design time, whereas others can only be set at run time. However, most properties
can be set at either time.
As a simple example, a control's Visible or Enabled property is often set during run time, in
response to actions by the user. For instance, we may want to disable a command button labeled
Print until the user has selected an object to print from a list of objects. Setting the Enabled
property of a command button whose name is PrintButton is easily done:
PrintButton.Enabled = False
In general, the choice of where to set a given property of a control is partly a matter of taste. I
favor setting properties in code because it tends to make the code more complete and thus more
readable. It can also make changing properties simpler. However, some fundamental properties,
such as Name and Caption, are best set at design time.
14.6.2.2 Activate button
Place a command button on the form, as in Figure 14-5 . Using the Properties window, set the
properties shown in Table 14-2 .
Table 14-2. Nondefault Properties of the Activate Button
Property
Value
Name
cmdActivate
Accelerator
A
Caption
Activate
TabIndex
1
14.6.2.3 Cancel button
Place another command button on the form, as in Figure 14-5 . Using the Properties window, set
the properties shown in Table 14-3 .
Table 14-3. Nondefault Prop erties of the Cancel Button
Property
Value
Name
cmdCancel
Accelerator
C
Caption
Cancel
TabIndex
2
Cancel
True
14.6.3 Create the Code Behind the UserForm
Now it is time to create the code behind these controls.
14.6.3.1 Cancel button code
Double click on the Cancel button to display the Click event code shell. Adding the line:
 
 
Search JabSto ::




Custom Search