i have a combobox...i have list of elements in it...on click of one particular item say "new" one of the textfields in my form say text1.text should get disabled.
Printable View
i have a combobox...i have list of elements in it...on click of one particular item say "new" one of the textfields in my form say text1.text should get disabled.
Whats the question?
i need a code to disable a text field in my form on selecting an item from a combo box...
Use the combobox click event and in there just set your textbox's .enable property to False.
Private Sub Combo1_click()
If Combo1.Text = "new" Then
Text1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "new"
Combo1.AddItem "old1"
Combo1.AddItem "old2"
Combo1.ListIndex = 0
End Sub
is this what u said? if so this doesn't seem to be working...the text box still stays enabled...
Private Sub Combo1_click()
If Combo1.Text = "new" Then
Text1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "new"
Combo1.AddItem "old1"
Combo1.AddItem "old2"
Combo1.ListIndex = 0
End Sub
if give this code..then on the click of all the three items the text field is disabled...but i jus want it to be disabled when i click new..
Works perfect for me. You werent using the Click event like I mentioned.
Code:Option Explicit
Private Sub Combo1_Click()
If Combo1.Text = "new" Then
Text1.Enabled = False
Else
Text1.Enabled = True
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "new"
Combo1.AddItem "old1"
Combo1.AddItem "old2"
Combo1.ListIndex = 0
End Sub
works fine thanks..