OnKeyDown - Allowing Other Access Shortcut Keystrokes to Pass Thro

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
 
S

Stuart McCall

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.
 

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