R
Roland Alden
I have a search box on a form and a handler for the keydown event, such that
when keydown sees KeyCode = 13 I do a search for a record matching what is
in the search text box.
Now I notice several things going wrong
Keydown seems to get called elsewhere on the form, not just when the search
box has the focus. In particular, when I enter a record number in the record
selector box and hit enter I get into my keydown handler. This seems wrong
but if not is there a best way to make sure the focus is in the search box
before I proceed to do a search and conflict with the desire on the part of
the user to go to a particular record number?
Secondly, I have this rather inelegant bit of code doing the search
Me.Recordset.find s
If (Me.Recordset.EOF) Then
Me.Recordset.MoveFirst
Me.Recordset.find s
End If
The problem is that if the search is going to hit record 5 but the current
record is > 5 then the user actually sees a bit of screen flashing as the
cursor goes to EOF, MoveFirst goes to record 1 and the search is done again.
Is there a way to avoid this? What I'd really like to see is a Find method
that was smart enough to wrap around automatically.
when keydown sees KeyCode = 13 I do a search for a record matching what is
in the search text box.
Now I notice several things going wrong

Keydown seems to get called elsewhere on the form, not just when the search
box has the focus. In particular, when I enter a record number in the record
selector box and hit enter I get into my keydown handler. This seems wrong
but if not is there a best way to make sure the focus is in the search box
before I proceed to do a search and conflict with the desire on the part of
the user to go to a particular record number?
Secondly, I have this rather inelegant bit of code doing the search
Me.Recordset.find s
If (Me.Recordset.EOF) Then
Me.Recordset.MoveFirst
Me.Recordset.find s
End If
The problem is that if the search is going to hit record 5 but the current
record is > 5 then the user actually sees a bit of screen flashing as the
cursor goes to EOF, MoveFirst goes to record 1 and the search is done again.
Is there a way to avoid this? What I'd really like to see is a Find method
that was smart enough to wrap around automatically.