Link to home
Start Free TrialLog in
Avatar of hhammack
hhammack

asked on

Activate command button only when combo box has value

I have a form with several command buttons on it.  I also have a combo box which contains various dates.  Some of the command buttons are only relevant if/when a particular date has been selected in the combo box.

I would like for those date-dependant command buttons to only be "active" when a date has been selected in the combo box.  If the combo box is blank (meaning no date has been selected, then I want those buttons to be "inactive".  I would like to have the buttons remain on the form in all cases, but perhaps be "dimmed out" or transparent when they are not to be pressed.

Anyone know what I'm talking about that could help me figure out how to get this done?  The less code the better, as I am a newbie in every sense of the word! :)

Thanks,
-howard.
Avatar of BillPowell
BillPowell

Heres a simple way.

Change the buttons enabled property to No.
Then in the afterupdate event for the combo box test for a value.

Private Sub MyCombo_AfterUpdate()
If Me!MyCombo <> "" Then
Me!MyButton.Enabled = True
End If
End Sub

You can use this for any of your buttons.

Hope this helps,

Bill
Avatar of hhammack

ASKER

Bill,

That works great, except that if the user selects a value in the cbo and then later decides to delete that value, then the button remains active.  How do I add parameters to make the button disable again if the user deletes the value?

ASKER CERTIFIED SOLUTION
Avatar of BillPowell
BillPowell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent!  Thanks!