Disabling a command button based a selection in a combo box

Somullins

Registered User.
Local time
Today, 06:23
Joined
May 9, 2012
Messages
17
Hello,

I have a form with a yes/no combo box. If the user enters yes, they are to use a command button to enter detail to the question. Can I disable the button if they select no? If so, how?

Thanks!
 
Use the ComboBoxes Change or AfterUpdate event. Use either line of the the following VBA code;

If Me.ComboboxName="No" Then Me.CommandButtonName.Enabled = False

Me.CommandButtonName.Enabled = (Me.ComboboxName="Yes")
 
If you used a Check Box rather than a Combo you could use the following;

Code:
Me.CommandButtonName.Enabled = Me.YourCheckBox

You'd just need that code in the Form's On Current and the Check box's On Click event.
 
Jon

Your Command worked for me a treat, However I wanted it to work in reverse so when the box is unchecked the button is enables. Being a complete novice to VB I would really appreciate if you could post the code for this, as I am :banghead:
 
You should just be able to put a "Not" in front of it. Try

Code:
Me.CommandButtonName.Enabled = Not Me.YourCheckBox
 

Users who are viewing this thread

Back
Top Bottom