B
Bob Richardson
What I'm trying to do is use a text box to filter my input, to make searches
easier. When the user types the first letter (e.g. "J") only records with a
last name starting with "J" appear. He next types "O" after the "J" and only
records starting with "JO" appear.
I've placed the following in my KeyUp event for the text box (txtLast)
If Me!txtLast = "" Then
Exit Sub
Else
Qry = "[LastName] like " & "'" & txtLast.Text & "*'"
Me.Filter = Qry
Me.FilterOn = True
txtLast.SelLength = 0
txtLast.SelStart = Len(Me!txtLast)
End If
This approach works perfectly UNTIL a combination of letters is typed that
results in no records appearing (e.g. "JOZ").
If I don't use the SelLength and SelStart methods, I can't type more than
one letter in my search box (txtLast) unless I use the mouse to set the
entry point at the end.
What the fix to this approach, or the better way to achieve my desired
result?
easier. When the user types the first letter (e.g. "J") only records with a
last name starting with "J" appear. He next types "O" after the "J" and only
records starting with "JO" appear.
I've placed the following in my KeyUp event for the text box (txtLast)
If Me!txtLast = "" Then
Exit Sub
Else
Qry = "[LastName] like " & "'" & txtLast.Text & "*'"
Me.Filter = Qry
Me.FilterOn = True
txtLast.SelLength = 0
txtLast.SelStart = Len(Me!txtLast)
End If
This approach works perfectly UNTIL a combination of letters is typed that
results in no records appearing (e.g. "JOZ").
If I don't use the SelLength and SelStart methods, I can't type more than
one letter in my search box (txtLast) unless I use the mouse to set the
entry point at the end.
What the fix to this approach, or the better way to achieve my desired
result?