Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox coding 1

Status
Not open for further replies.

TheRealDeal

Technical User
Nov 16, 2001
187
US
Let me explain my scenario first before I ask the question. I have a combobox that has 2 columns sorted by the second ASC and first DESC. The first is numeric and the return column while the second is additional text. The TypeAhead feature works just as I would expect it to. My question though is since my listing can be lengthy, is it possible to see the first listing for any D entries when I type a "D" and DA when I type "DA"?
 
I am afraid I am missing your point. If you type a letter or two into a combobox and then click the dropdown arrow, you will the first entry with that / those letters highlighted and the list continuing from that point. I do not think this is what you mean, is it?
 
Say the example below is the contents of the combobox. Instead of choosing the Employee ID(Col1), say the list is extremely long and I know the name of the Employee(Col2). I don't want to change the TypeAhead for the EmployeeID since I ultimately want the EmployeeID returned; but what I would like is the added capability to start typing the name of the Employee and find the appropriate entry.

Is it possible, given I don't want to change the example's layout, to position the highlighter to correct entry. Additonally, each column can be common-knowledge amongst users.

12345 Ann
12346 Bob
12347 Chris
12348 Dawn
12349 Eugene
 
This may suit, but it is for one letter only:
Code:
Private Sub Combo0_Change()
Dim rs As DAO.Recordset

If Not IsNumeric(Me.Combo0.Text) Then
    strText = Me.Combo0.Text
    Set rs = CurrentDb.OpenRecordset(Me.Combo0.RowSource)
    
    rs.FindFirst "FirstName Like '" & strText & "*'"
    If rs.NoMatch Then
        Me.Combo0.Undo
    Else
        Me.Combo0 = rs!ID
    End If
End If
        
End Sub

You could have more letters if you want to do something similar with an After Update event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top