enable field based on option group selection

G

Guest

I have an option group with 3 radio buttons. I would like another field on
the form to be enabled if one of these radio buttons is selected, but cleared
and disabled if either of the other two are selected. I have tried different
code, but nothing works. If I understand correctly, if the property values of
the buttons are 1, 2 and 3, the option group is given the value of the
corresponding button selection. But I can find no 'option group' entity on
which to base some code such as:

If OptionGroup = "2" Then
OtherField.Enabled = True
Else OtherField = ""
OtherField.Enabled = False
End If

Assuming this is code is good (I'm new at this), where would I place it?

Any help is much appreciated.

RipperT
 
D

Dan Artuso

Hi,
Your OptionGroup control will have a name.
The default one is FrameX
where X is some number.

You can of course change this from it's properties sheet.
Sometimes it's a bit tricky to select the control if you don't know how.
You have to click on the border, not inside it or on the label
(which by the way should say something like FrameX).

Anyway you can then use your code in the Frames AfterUpdate event

If Me.yourFrame = 2 Then
OtherField.Enabled = True
Else
OtherField = ""
OtherField.Enabled = False
End If
 
G

Guest

Outstanding, Thanx a million!

Rip

Dan Artuso said:
Hi,
Your OptionGroup control will have a name.
The default one is FrameX
where X is some number.

You can of course change this from it's properties sheet.
Sometimes it's a bit tricky to select the control if you don't know how.
You have to click on the border, not inside it or on the label
(which by the way should say something like FrameX).

Anyway you can then use your code in the Frames AfterUpdate event

If Me.yourFrame = 2 Then
OtherField.Enabled = True
Else
OtherField = ""
OtherField.Enabled = False
End If
 
G

Guest

New problem: enabling and disabling OtherField does not hold from record to
record. Once it is enabled it stays enabled in subsequent records even tho
the default value is set to "1" which, according to the IF statement is the
"else" condition under which OtherField should be disabled. I need to add
more code so that if the option group value is "2", then OtherField is
enabled, a value placed in it, and have it remain enabled and hold the value
when navigating to and from the record. Can you help? Thanx alot!

Ripper
 
J

John Vinson

New problem: enabling and disabling OtherField does not hold from record to
record.

Put the same code in the Form's Current event.


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top