Select OptionButton - dim controls

  • Thread starter Thread starter Jean
  • Start date Start date
J

Jean

Hello,

I want to do the following, and am pretty new to
programming forms, so can someone please gimme a hand?

I have a form which I designed merely as a prototype. This
form is currently not connected to an underlying data
source(table).
It has an OptionGroup, e.g. named fraCarType1. This option
group has two OptionButtons, e.g. optBrand1 and optOther1.
If the user selects optBrand1, the controls (e.g. a
CommandButton, another OptionGroup) which appear below the
other (optOther1) should become disabled(greyed out).

What is the simplest way of doing this? Which event
procedure do I program, and with what code?

Thank you for any ideas!
 
Hi Jean

Use the AfterUpdate event of your option group:

Private Sub fraCarType1_AfterUpdate()
' assume OptionValue is 1 for optBrand1 and 2 for optOther1
' enable controls for option 1:
cmdButton1.Enabled = (fraCarType1 = 1)
fraOtherOptiongroup.Enabled = (fraCarType1 = 1)
' enable controls for option 2:
cmdButton2.Enabled = (fraCarType1 = 2)
fraThirdOptiongroup.Enabled = (fraCarType1 = 2)
End Sub

You should also call this procedure (Call fraCarType1_AfterUpdate) from your
Form_Current procedure, so that the controls are all correctly
enabled/disabled as you navigate from record to record.

If you have lots of controls which are affected, you might consider using a
tab control instead.
 
Back
Top