Activate cmd button from keyboard

T

tina

instead of activating my command button with an Alt+letter combination via
an ampersand+letter in the Caption property, i want to activate it with a
Ctrl+letter combination. does anyone know of a way to set that up similar to
the way the Alt+letter is set up?
if not, does anyone know of a way to set up an Autokeys macro to be
available only when a particular form is open?
tia, folks! :)
 
A

Allen Browne

Use the KeyDown event of the form (remembering to turn KeyPreview on). The
Shift argument informs you if the Ctrl key is down.

You could use the Condition column of the AutoKeys macro to see if
Screen.ActiveForm.Name matches the form you are expecting. However, that
could error if no form is active, so you probably need to use the RunCode
action in the macro, to call a function that has error handling to avoid
that problem.
 
V

Van T. Dinh

Try setting the KeyPreview Property of the Form to Yes / True and use the
KeyDown Event of the Form to run the CommandButon_Click Event.

See Access VB Help on KeyPreview Property and KeyPress Event.
 

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