Hi,
I have a FORM based on a Table with some text fields, some combo and three command button.
What I want is..
If I select a combo value = "NO" then all the text fields and other combo will be disabled.
How to achieve that?
regards
Saikat
Hi,
I have a FORM based on a Table with some text fields, some combo and three command button.
What I want is..
If I select a combo value = "NO" then all the text fields and other combo will be disabled.
How to achieve that?
regards
Saikat
This type of thing is one way:
http://www.baldyweb.com/ConditionalVisibility.htm
If you have a lot of controls, you may want to loop them instead of listing each.
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)>