StaceyJ said:
Hi Randy,
Thanks for your response. I am having a few problems running the code,
though. I changed the frame1.value references to read host_type.value
(the
name of my Option Group control frame. But I'm not sure how to work with
the
"MyOtherControls1.enable = Not Status" portion. Do I just rename the
"MyOtherControls1" part to the name of one of my controls, and create a
running list that might read something like "name.enable=Not Status" or
something like that? I tried it, and the debugger started up and took me
to
the Private Sub line of that After Update event.
I can't seem to quite discern what is wrong.
I also am wondering how I will convert your code so that when value 1 is
selected, I only enable certain fields, and when value 2 is selected I
enable
different fields.
I really appreciate your guidance.
Happy New Year!
--Stacey
Stacey,
In the snippet code "MyOtherControls1" refers to any control you want to
enable/disable based on the current value of your Option Group/Frame. You
could replace that and use the name of the real control on your form. For
instance, if you want to disable/enable an OK button then it will be
something like:
cmdMyOKbutton1.Enable = Not Status
....And if you have more controls you want to disable/enable, just keep
adding below
cmdMyOKbutton1.Enable = Not Status
cmdMyOKbutton2.Enable = Not Status
cmdMyOKbutton3.Enable = Not Status
Please note that there might be cases where you want to do the opposite for
a specific control. For example, the following code will always have
different alternate Status.
cmdMyOKbutton1.Enable = Not Status
cmdMyOKbutton2.Enable = Status
cmdMyOKbutton3.Enable = Not Status
When the second button is enabled the other two will be disabled, and when
they are enabled the second button will be disabled. Adapt the code to your
scenario.
So it will be something like this
Private Sub Frame1_AfterUpdate()
Dim Status as boolean
' Process the selected value of the frame and
' determine whether disable or enable the co-related controls
If IsNull(Frame1.value) then
Status = False
Else
If Frame1.Value = 1 then
Status = True
Else
'this is value 2
Status = False
End If
End If
' Disable/Enable the co-related controls based on
' the status variable
cmdMyCommandButton1.Enable = Not Status
cmdMyCommandButton2.Enable = Not Status
cmdMyCommandButton3.Enable = Not Status
txtMyTextBox1.Enable = Not Satus
txtMyTextBox2.Enable = Not Status
End Sub
Hope it helps