PsuedoTypeahead for Combo/List box using text box
No attachments for this post
To allow a user to typeahead to a specific item in a list/combo box allowing a little more flexability.
Original Author: James Travis
Data entry in text box.
Basically this demonstrate how to loop thru a combo/list box control and compare the typed data to the text value displayed in a the control boxes and select the item. Usefully in large selection lists.
Position and selects the first matching item.
Depending on if the items are sorted the jumping around and selection may look unusual.
'You will need 3 controls
'TextBox = Text1
'ComboBox = Combo1
'ListBox = List1
'Then you can cut and paste.
Private Sub Form_Load()
'Load our test items.
Private Sub Text1_Change()
Dim cmbInd As Long, lstInd As Long
'0 is the last item in the list not the first
For cmbInd = (Combo1.ListCount - 1) To 0 Step -1
If UCase(Left(Combo1.List(cmbInd), Len(Text1.Text))) = UCase(Text1.Text) Then Combo1.ListIndex = cmbInd 'Find and set the selected combo item
For lstInd = (List1.ListCount - 1) To 0 Step -1
If UCase(Left(List1.List(lstInd), Len(Text1.Text))) = UCase(Text1.Text) Then List1.Selected(lstInd) = True 'Find and set the selected list item
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.