As Paul said, if you're talking about a fair number of Controls being Enabled/Disabled, you may want to set the Tag Property of those to be handled, then loop through them and Enable or Disable, according to the Value of your Combobox. Code also needs to be in the Form_Current event in order to have the formatting stay appropriate as you move from Record-to-Record.
In Form Design View
- Hold down <Shift> and Click on the Controls to be Looped, in order to select them
- Right-Click then Click on Properties
- Go to Other Tab
- In the Tag Property enter Tagged (without Quotation Marks)
Now use this code, replacing ComboboxName with the actual name of your Combobox.
Code:
Private Sub ComboboxName_AfterUpdate()
Dim ctl As Control
If Me.ComboboxName = "No" Then
For Each ctl In Me.Controls
If ctl.Tag = "Tagged" Then
ctl.Enabled = False
End If
Next
Else
For Each ctl In Me.Controls
If ctl.Tag = "Tagged" Then
ctl.Enabled = True
End If
Next
End If
End Sub
Code:
Private Sub Form_Current()
Dim ctl As Control
If Me.ComboboxName = "No" Then
For Each ctl In Me.Controls
If ctl.Tag = "Tagged" Then
ctl.Enabled = False
End If
Next
Else
For Each ctl In Me.Controls
If ctl.Tag = "Tagged" Then
ctl.Enabled = True
End If
Next
End If
End Sub
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007