Activate cmd button from keyboard

  • Thread starter Thread starter tina
  • Start date Start date
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! :)
 
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.
 
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.
 
Back
Top