Using multiple sets of Option Buttons

Figure 18-7 shows a custom dialog box with three sets of OptionButtons. If your UserForm contains more than one OptionButtons set, make sure that each set of OptionButtons works as a set. You can do so in either of two ways:

1 Enclose each set of OptionButtons in a Frame control. This approach is the best and also makes the dialog box look better. It's easier to add the Frame before adding the OptionButtons. You can, however, also drag existing OptionButtons into a Frame.

1 Make sure that each set of OptionButtons has a unique GroupName property. If the OptionButtons are in a Frame, you don't have to be concerned with the GroupName property.

Figure 18-7:

This dialog box contains three sets of Option Button controls.

Figure 18-7:

This dialog box contains three sets of Option Button controls.

Only one OptionButton in a group can have a value of True. To specify a default option for a set of OptionButtons, just set the Value property for the default item to True. You can do this directly in the Properties box or do it using VBA code:

UserForml.OptionButtonl.Value = True

This example is available at this book's Web site. It also has code that displays the selected options when the user clicks OK.

0 0

Post a comment