Maciej said:
I've designed a form, which contains 2 option buttons and 4 text boxes. What
I want to acheive is to make 2 of these textboxes enabled (active) if one
of option buttons is checked and keep the other 2 textboxes disabled.
In response to private email:
The option button has no event as "on Click" (at least in Access 2003), but
I used the statement you gave me, in "on Got Focus".
It worked just perfect!!
Please keep the correspondence in the newsgroup so everyone
can benefit.
That won't work in all cases. There are other ways for a
control to get the focus besides clicking on it.
If your option button doesn't have a Click event, it's
because you have the button inside an optopn group. In this
situation it's the group that has the Click event, not the
options within the group.
Technically, it is a little better to use the group's
AfterUpdate event instead of the Click event. To determine
which option was selected, look at the group's Value.
Assuming the OptionValues are 1, 2, ... you can use code
like:
Select Case Me.optiongroup
Case 1
Me.textbox2.Enabled = True
Me.textbox4.Enabled = True
Me.textbox1.Enabled = False
Me.textbox3.Enabled = False
Case 2
Me.textbox2.Enabled = False
Me.textbox4.Enabled = False
Me.textbox1.Enabled = True
Me.textbox3.Enabled = True
Case 3
. . .
End Select
As long as you understand how that works, then that code can
be reduced to:
Me.textbox2.Enabled = (Me.optiongroup = 1)
Me.textbox4.Enabled = (Me.optiongroup = 1)
Me.textbox1.Enabled = (Me.optiongroup = 2)
Me.textbox3.Enabled = (Me.optiongroup = 2)
. . .