OnKeyPress Docmd.findrocord A2002

K

Ken

It seems this has been touched on in the history, but
not quite like this.
I have a subform with several customers. The form is in
database view and gets its records from a query. I have
it set up so you can double click on any field and edit
the customer record.
What I would like to do is have it so when you press a
key, the record that starts with that key is found. It
works with the Binoculars (find). I have been researching
the "OnKeyPress", and Docmd.findrecord, but I don't know
how to tell the "FindRecord" the key pressed.
Any Help Is greatly appreciated.
 
T

TC

You can see which key has been pressed by using the KeyPress event of the
textbox in which the user is typing. This will hopefully be an >unbound<
textbox. (If you let them type keys into a >bound< textbox, this will start
to edit that record, unless you discard the keystrokes by setting them to 0
in the KeyPress event.)

Once you know that the user pressed "x" (for example), this will move to the
first record where the field named XYZ has a value starting with "x":

(untested)

with me.recordsetclone
.findfirst "[XYZ] LIKE ""x*"""
if .nomatch then
msgbox "no such record"
else
me.bookmark = .bookmark
endif
end with

Copy & paste that code directly. It has some full-stops & other things that
are easy to miss, or get wrong.

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top