Hello there,
I've made a combobox with an filter to search for partial matched values in my database. This is the code i use:
Private Sub ComboBox1_Change()
Call OptimizeCode_Begin
Dim myVal As String, i As Long, ii As Long
With Me.ComboBox1
If .Text = "" Then
.List = myList
Else
myVal = .Text
For i = .ListCount - 1 To 0 Step -1
If Not UCase$(.List(i, 3)) Like "*" & UCase$(myVal) & "*" Then .RemoveItem (i)
Next
End If
End With
Call OptimizeCode_End
End Sub
There is one problem. When i start typing with the dropdown list expanded, and press a few letters, it does not remove the last item in the list. Now i get a list of matching strings, but there is still one value at the bottum of the list stuck, when its supposed to be deleted. I recon its because you take 1 from the listcount. But without this part, the code does not work.
It looks like this:
I would be really gratefull if someone could help me.
Bookmarks