Re: code for an <ALT + R> key



Hi Steve,

If possible I'd do it with command buttons with their accelerator keys
set to the letters I wanted to capture as Alt+R etc. If necesssary the
the buttons could be hidden behind something else on the form.

Otherwise, the key codes for KeyUp and KeyDown are documented in the
help topic "Keycode Constants"; codes for the letter keys are the same
as the ASCII code for the uppercase letter, so R is 82.

To check for Alt in addition to a letter, you have to read the Shift
argument of the event procedure, e.g.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = acAltMask Then 'Alt is pressed but not Ctrl or Shift
Select Case KeyCode
Case 82 'R
'Do something
Case 83 'S
'Do something else
Case Else
'Do nothing
KeyCode = 0
End Select
End If
End Sub

On Tue, 25 Oct 2005 11:51:06 -0700, "SteveInBeloit"
<SteveInBeloit@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>Hi,
>I would like to put code behind some <alt> keys in a form. I am assuming I
>can put it on the Key_down event. Then I should check KeyCode like:
>If KeyCode = vbKeyTab then
> Do something
>End if
>
>I can't seem to find what to compare KeyCode to for an Alt + R. Are there
>any gotcha's when doing this?
>
>Thanks,
>Steve

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

.