-
I need a way, using an ordinary ComboBox (not Drop-Down List), to discard any typed-in entries that don't match up with an item on the list.
For example, if someone types something in, then tabs out of the ComboBox, and whatever they typed in doesn't correspond to something already in the list, the ComboBox.Text will be reset to " " in the validation code.
I'm sure this can't be too difficult but my brain is too tired. Can anyone help me?
-
here this should work:
Code:
Sub Combo1_LostFocus()
For a = 0 to Combo1.listcount-1
if ucase(combo1.list(a))=ucase(combo1.text) then
exit sub
end if
combo1.text=""
Next a
End Sub
:D Hope this helps,
-
Actually...
There is a little bug in the previous code. it will not detect anything from the second item in the list down. If we make a slight change it works fine. ;)
Here is the modified code:
Sub Combo1_LostFocus()
For a = 0 to Combo1.listcount-1
if ucase(combo1.list(a))=ucase(combo1.text) then
exit sub
end if
Next a
combo1.text=""
End Sub
-