OnKeyDown - Allowing Other Access Shortcut Keystrokes to Pass Thro

  • Thread starter Thread starter Larry A. Filoso
  • Start date Start date
L

Larry A. Filoso

In some of my continuous forms, from within the form's OnKeyDown event
procedure I call a sub which lives in a General Module. That sub examines the
keys pressed and traps Ctrl plus arrow keys for alternate functionality, but
I would like other key combos (especially Ctrl+' to copy contents of field
above) to operate as usual.
I tried sendkeys from the sub, but that loops back to sub. I tried setting
KeyCode to 0, but the copy field function still doesn't work.
Any suggestions?
Thanks...
Larry A. Filoso
 
Larry A. Filoso said:
In some of my continuous forms, from within the form's OnKeyDown event
procedure I call a sub which lives in a General Module. That sub examines
the
keys pressed and traps Ctrl plus arrow keys for alternate functionality,
but
I would like other key combos (especially Ctrl+' to copy contents of field
above) to operate as usual.
I tried sendkeys from the sub, but that loops back to sub. I tried setting
KeyCode to 0, but the copy field function still doesn't work.
Any suggestions?
Thanks...
Larry A. Filoso

The trick is to set KeyCode to 0, but *only* when you want the key
'swallowed'. Let's say you have a select case construct:

Select Case KeyCode
Case vbKeyA
'Do something
KeyCode = 0
Case vbKeyB
'Do something else
KeyCode = 0
End Select

That way the KeyCode is only swallowed when you've reacted to it. All other
KeyCodes will pass through the procedure unaffected.
 
Back
Top