Hey SandB
If you are interested, there is a course on Udemy that walks you through exactly how to do what you are looking for.
the course is called "Microsoft Access VBA for non programmers - You can do this"
just click in the field you want and start typing the name and the form will automatically start sorting the records as you type
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ctl As Control
Dim fldName As String
Dim rst As Recordset
On Error GoTo ErrHandler
'MsgBox ("the keycode is " & KeyCode)
Select Case KeyCode
Case 122
If Shift <> 4 Then
KeyCode = 0
End If
Case vbKeyEnd
KeyCode = 0
DoCmd.RunCommand acCmdRecordsGoToLast
Case vbKeyHome
KeyCode = 0
DoCmd.RunCommand acCmdRecordsGoToFirst
Case vbKeyUp
KeyCode = 0
DoCmd.RunCommand acCmdRecordsGoToPrevious
Case vbKeyDown
KeyCode = 0
DoCmd.RunCommand acCmdRecordsGoToNext
Case vbKeyRight, vbKeyLeft
Case 9, 13 'Tab or enter key
Case 8 'Backspace Key
Case 48 To 57, 65 To 90
Set ctl = Screen.ActiveControl
fldName = ctl.Name
If fldName <> LastFld Then
srchval = ""
End If
LastFld = fldName
Select Case UCase(fldName)
Case "CityFilt" ' City Filt Fix
Exit Sub
End Select
srchval = srchval & Chr(KeyCode)
KeyCode = 0
If fldName = "Address" Then
srchCrit = "[" & fldName & "] Like '*" & srchval & "*'"
Else
srchCrit = "[" & fldName & "] Like '" & srchval & "*'"
End If
Set rst = Me.RecordsetClone
rst.FindFirst srchCrit
If rst.NoMatch Then
MsgBox (" Record not found! ")
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Case 107, 187
If srchval = "" Then
KeyCode = 0
Exit Sub
End If
Set ctl = Screen.ActiveControl
fldName = ctl.Name
KeyCode = 0
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
rst.FindNext srchCrit
If rst.NoMatch Then
MsgBox (" Record not found! ")
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Case 109, 189
If srchval = "" Then
KeyCode = 0
Exit Sub
End If
Set ctl = Screen.ActiveControl
fldName = ctl.Name
KeyCode = 0
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
rst.FindPrevious srchCrit
If rst.NoMatch Then
MsgBox (" Record not found! ")
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Case 27
KeyCode = 0
srchval = ""
Case Else
KeyCode = 0
End Select
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2046
Case Else
MsgBox Err.Number & " " & Err.Description
End Select
Resume Next
End Sub