Assign a 'hot Key'

L

louonline

Hi,
On a form, how can I assign a HotKey (say F12) so that when it is
pressed the curser will jump to a certain Field no matter what field
the curser is in at the time or what the Tab Order of the form is.

I think the 'SendKeys' function is what I need but I'm not sure how or
where to put the code to give me the desired action.

Regards,
Lou
 
R

RoyVidar

louonline wrote in message
Hi,
On a form, how can I assign a HotKey (say F12) so that when it is
pressed the curser will jump to a certain Field no matter what field
the curser is in at the time or what the Tab Order of the form is.

I think the 'SendKeys' function is what I need but I'm not sure how or
where to put the code to give me the desired action.

Regards,
Lou

In the forms keydown event, try something like this

if keycode = vbkeyf1 then
me!txtSomeControl.SetFocus
keycode = 0 ' important! to cancel the keystroke
end if

The keypreview property of the form must be set to Yes.

Then there's also the AutoKeys macro which can be used, but that would
create global shortcut key assignements.

F12 is a function key that might be in use (save as), so using it to
other purposes might confuse the users.

One quite simple method of creating a shortcut to set focus to a
control, is to play with it's attached label. Say the control txtText
has an attached label with the caption "Enter SSN", then by typing for
instance "Enter &SSN", it will become an underlined letter, which will
give focus to the control when using Alt + s.
 
L

louonline

Thank you Roy.
I would like to keed it simple so I would prefer to use one of the
Function keys. I picked F12 at random as an example.
(is not F1 the 'Help' key in MS access?)
I'll give your code a go and see what happens.
Thanks again.
Regards,
Lou
 

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

Similar Threads

Tab 1
GoToControl Help 2
hot-key removal 3
Curser size 3
Help Needed for Assigning of Hot Key For a Command Button In acces 1
Assign a hot key 1
Hot Keys 1
Access 2003 Form Tab Order programing 9

Top