A little baffled here at what I am seeing.... for some reason the following code will add duplicates (and sometimes even more) to my combo box of the names it finds a matching letter of...
Let me explain. The following code is supposed to activate whenever the combo box value changes...(I have set the Matchentry property to MatchEntryNone)..It is supposed to take that change and refill my combo box with values that have the text anywhere in them.
So if my box is filled with...
"Adam Spencer"
"Jonny Applesauce"
"Ceasar Milan"
"Tony Yolo"
(Not sure if it would match to the capital A, but that's not the problem anyway...)
The code should adjust the box to exclude "Tony Yolo" because he doesn't have an "a" anywhere in his name.
The reason I am baffled is because the code works perfectly when I step through it...but when I'm testing the userform it will do the doubles and triples...It does get the correct values but it will double them up.
Let me explain. The following code is supposed to activate whenever the combo box value changes...(I have set the Matchentry property to MatchEntryNone)..It is supposed to take that change and refill my combo box with values that have the text anywhere in them.
So if my box is filled with...
"Adam Spencer"
"Jonny Applesauce"
"Ceasar Milan"
"Tony Yolo"
(Not sure if it would match to the capital A, but that's not the problem anyway...)
The code should adjust the box to exclude "Tony Yolo" because he doesn't have an "a" anywhere in his name.
The reason I am baffled is because the code works perfectly when I step through it...but when I'm testing the userform it will do the doubles and triples...It does get the correct values but it will double them up.
Code:
Private Sub cbName_Change()
cbcoll.Clear
With Me.cbName
For thing = 0 To Me.cbName.ListCount - 1
cbcoll.Add Me.cbName.List(thing)
Next
FilterComboBox1 Me.cbName.Text
End With
End Sub
Public Sub FilterComboBox1(strFilter As String)
Me.cbName.Clear
For Each strChoice In cbcoll
If InStr(1, strChoice, strFilter) <> 0 Then
Me.cbName.AddItem strChoice
End If
Next
End Sub