Ok, I'm sure everybody is familiar with the feature in Windows Explorer where you can start typing a file name and it will jump to the file with the closest name to that which you are typing. I was just wondering whether there was anyway of doing something similar in a form. Where say you could begin to type the last name in a field in a table of customers for example and it would narrow the recordset down based on the letters you are typing.
The only way I can think of at the moment is to have a select query which is triggered by the textboxes on change event and then set the query as the forms control source. However this seems a little bit unprofessional and may come unstuck.
How about using FindFirst instead of requerying? I think you need at least Acc2k for that to work though.
Something like that:
Private Sub TextWhatever_Change()
Dim rst As DAO.Recordset
Dim TextLen As Long
Static OldTextLen As Long
TextLen = Len(Me.TextWhatever.Text)
'only search if the user appended something to the search string
If TextLen > OldTextLen Then
Set rst = Me.Recordset
'find the record
rst.FindFirst "Sortierbegriff LIKE '" & EscapeTicks(Me.TextWhatever.Text) & "*'"
'let the user continue typing normally
Me.TextWhatever.SelLength = 0
Me.TextWhatever.SelStart = TextLen
OldTextLen = TextLen
Probably the fastest way (minimal coding) is to use a combo box and the Auto Expand property set to Yes like Jerrie suggested. If you automatically pop up the combo box list with :
In the Got Focus event of the combo box then it will show you more than one name. You can even show as many names as you like with the List Rows property of the combo box.
The only other way I can think of is turning on Key Preview and putting some code in the On Key Press event of the combo box. Did you want to 'jump' to the best match or filter for the best match? The difference being, the filtering would remove items from the list and the jump would just move up an down the list.
Not really sure that this is what you wanted but take a look at the sample database I posted here. When the form opens, Tab 3 times to move to the JobNameLookup field...(ComboBox) and start typing either of these words:
Note, as you type the first "H" it pulls in one of the choices, then type another letter and another. As you fill it in more you get closer to a possible match.
hope this is what you needed.
have a nice one,