Disabling a combobox based on selection in another combo box

vbadvt
10-05-2009, 07:45 AM
Hello all,

I have a form in which I need to disable a combobox based on a selection in another combobox.

For example, there are 2 comboboxes C1 and C2.

C1 has a dropdown list with values apple, banana, orange, grapes, kiwi.

When the user chooses orange from the list in C1, the combo box C2 should automatically be disabled. Can someone tell me how to do this? I am new to VB and I am still learning. Please help ASAP.. Thanks

gibra
10-05-2009, 09:32 AM
Check the Combo1.Text property value in Combo1_Click event


Private Sub Combo1_Click()
If Combo1.Text = "orange" Then
Combo2.Enabled = False
Else
Combo2.Enabled = True
End If
End Sub

Or, I prefer this:


Private Sub Combo1_Click()
Combo2.Enabled = (Combo1.Text = "orange")
End Sub


:D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum