Microsoft Developer Network >
Forums Home
>
Microsoft ISV Community Center Forums
>
Visual Basic for Applications (VBA)
>
Excel userform problem
Excel userform problem
- hello everybody, I need to know whether it is possible (and how) to block textboxes of a userform if the value of a combobox is x,y,w,z
thanks for any help
Answers
- if you want the textbox to be disabled based on another control then try setting the enabled property in an event related to the other control.
in other words, if the textbox being enabled depends on the combobox selection then use the combobox events
FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial- Marked As Answer bys7yzrs Thursday, November 05, 2009 8:52 PM
- Hello Jeff, thanks for the very quick reply. The code works but... not immediately. Here is what I did and what I get:
in VB I selected the textbox I need to be disabled and this is the code I wrote:
Private Sub GWeight_Change()
If Me.ComboAirline.Text = "DL" Then
Me.GWeight.Enabled = False
End If
End Sub
The result is that I can still write at least 1 letter in the textbox before it is disabled (tab order of textbox is 4). am I doing something wrong?
Thanks for you patience and help- Marked As Answer bys7yzrs Thursday, November 05, 2009 8:52 PM
All Replies
- choose the event you want to handle the ComboBox checking with and try this:
If Me.yourComboBox.Text = " x,y,w,z" Then
Me.yourComboBox.Enabled = False
End If
FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial - Hello Jeff, thanks for the very quick reply. The code works but... not immediately. Here is what I did and what I get:
in VB I selected the textbox I need to be disabled and this is the code I wrote:
Private Sub GWeight_Change()
If Me.ComboAirline.Text = "DL" Then
Me.GWeight.Enabled = False
End If
End Sub
The result is that I can still write at least 1 letter in the textbox before it is disabled (tab order of textbox is 4). am I doing something wrong?
Thanks for you patience and help- Marked As Answer bys7yzrs Thursday, November 05, 2009 8:52 PM
- if you want the textbox to be disabled based on another control then try setting the enabled property in an event related to the other control.
in other words, if the textbox being enabled depends on the combobox selection then use the combobox events
FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial- Marked As Answer bys7yzrs Thursday, November 05, 2009 8:52 PM
- yes, now it works as I wished.
thank you very much for your help!!!!

