combobox value blank
You could have a subroutine that checks all the input to see if it's valid
before you enable the combobox.
I made a small userform with a combobox, textbox and two commandbuttons. I
wanted to make sure that there was something in the textbox and something in the
combobox before enabling the commandbutton2 button.
Option Explicit
Private Sub ComboBox1_Change()
Call CheckInput
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
Call CheckInput
End Sub
Private Sub UserForm_Initialize()
With Me.ComboBox1
.AddItem "A"
.AddItem "B"
.AddItem "C"
.ListIndex = -1
.Style = fmStyleDropDownList
End With
Me.CommandButton2.Enabled = False
End Sub
Private Sub CheckInput()
Dim Ok As Boolean
Ok = True
If Me.ComboBox1.ListIndex < 0 Then
Ok = False
ElseIf Me.TextBox1.Value = "" Then
Ok = False
End If
Me.CommandButton2.Enabled = Ok
End Sub
ranswert wrote:
I have a combo box on a form. Sometimes when the form is called the combo
box is blank. I have a button 'OK' that gets the value from the combo box.
I that value is blank my code for the 'OK' button doesn't work. There are no
blank cell in the row source for the combo box. Is there a property for the
combo box that can be set so that it won't have a blank value before the drop
arrow is pressed?
Thanks
--
Dave Peterson
|