Nick said:
I am using an option groups to turn certain textboxes off in a sub form. If
I use say option 2 how can I turn off the textbox named opportunities and
hrOffered.
A general approach (might not be worth the effort for just
two text boxes) is to set the Tag property of the controls
you want to manipulate to something such as "OnOff". This
way, you can loop through the controls collection and set
the property (or properties) without knowing each control's
name or having duplicated code for each control.
Create a Sub procedure in a standard module:
Public Sub SetProps(frm As Form, switch As Boolean)
Dim ctl As Control
On Error Resume Next ' incase control does not have prop
For each ctl In frm.Controls
If ctl.Tag = "OnOff" Then
ctl.Locked = switch ' or Enabled, Visible, etc
End If
Next ctl
End Sub
Then any form can manipulate a set of controls in any open
form with code like:
SetProps Forms!nameofform, False ' or True
For a main form to do this for one of its subforms:
SetProps Me.subformcontrol.Form, False