Hello,
I'm working on an old projet. I created a Combobox with a list of value from a variable source (SQL), so I can't hard coded the values for validation.
I use this code to grab the 1st value in the list without having to use the mouse to select.
When I validate, the combobox.listindex will return the right value when I use the mouse-click but will always return -1 when I type in.Code:Private Sub ComboTypeAppel_Change() Dim i As Long Dim lngText As Long 'If firing in response to a backspace or delete, don't run the auto-complete 'complete code. (Otherwise you wouldn't be able to back up.) If blnBackSpace = True Or ComboTypeAppel.Text = vbNullString Then blnBackSpace = False Exit Sub End If 'Run through the available items and grab the first matching one. For i = 0 To ComboTypeAppel.ListCount - 1 If InStr(1, ComboTypeAppel.List(i), ComboTypeAppel.Text, vbTextCompare) = 1 Then 'Save the SelStart property. lngText = ComboTypeAppel.SelStart ComboTypeAppel.Text = ComboTypeAppel.List(i) 'Set the selection in the combo. ComboTypeAppel.SelStart = lngText ComboTypeAppel.SelLength = Len(ComboTypeAppel.Text) - lngText Exit For End If Next End Sub
How can I validate that the value of the combobox is part of the valut list ?
Please provide code, I'm a newbie working on some else old code.
Thanks




Reply With Quote
