Microsoft Office Tutorials and References
In Depth Information
A CheckBox on your UserForm can serve one of
two purposes: to provide users with an option that
is of the Yes/No variety, without a superfluous
Message Box to present the option, or to provide a
pair of OptionButtons (covered in the next section).
Simply, a single CheckBox is inferred to mean Yes
or OK if it is checked, and No if it is not checked.
As you develop more complex UserForms, you will
want to provide your users with convenient options
for viewing — or not viewing — interface objects
that might be irrelevant to them in some cases,
and useful in others. For example, Figure 19-9
shows the same UserForm in two situations, where
the user can check or uncheck the CheckBox
captioned Show List of Months. If the CheckBox is
unchecked, neither the ListBox nor the Label above
it will be visible, but if the CheckBox is checked,
those controls do appear. The code associated with
the CheckBox follows.
Private Sub CheckBox1_Click()
With CheckBox1
figurE 19-9
If .Value = True Then
Label1.Visible = True
ListBox1.Visible = True
Label1.Visible = False
ListBox1.Visible = False
End If
End With
End Sub
Users appreciate having a say as to what they see on a form, which helps give
them some control over the form’s navigation process. However, as the
workbook’s developer, your primary objective is to design a smart form. In this
example, if the selection of a month name is a mandatory action in the UserForm’s
overall process, you would not consider building in the option of hiding a
ListBox of month names. You’ll often see a single CheckBox on a UserForm
when a simple preference is to be indicated, such as including a header on all
printed pages, or performing the same action on all worksheets.
Search JabSto ::

Custom Search