Hi Andi,
I just use the Keypress event and check for the ASCII values of the
control characters, e.g.
Private Sub Form_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 3
MsgBox "Ctrl-C"
Case 4
MsgBox "Ctrl-D"
Case Asc("C")
MsgBox "C"
End Select
As for the problem with your code, I haven't tried to think it through
completely, but the value of acCtrlMask is 2, so this
acCtrlMask <> 0
always evaluates to True.
If you want a condition that is true only when the Control key is
pressed, you need
(Shift And acCtrlMask) > 0
For more, see Help, or
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/ac
evtKeyDown_HV03079790.asp
>I am having problems being able to track when CTRL and C are pressed at the
>same time. I have added the following to the keydown event of my Flexgrid
[quoted text clipped - 14 lines]
>
>Andi
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
Andibevan - 28 Feb 2006 12:42 GMT
Hi John - Thanks for your suggestion but unfortunately it didn't work form
me.
This may because the flexgrid has the focus rather than the form. As a
result I moved your code to the Flexgrid keypress event and it still doesn't
work.
If I add the line debug.print keyascii - most combinations of keypresses
(i.e. ctrl+d, ctrl+r) work and generate an ascii value in the immediate
window. When I do ctrl+c, ctrl+v or ctrl+x - no ascii values are
generated - it seems as though the combination of ctrl+c triggers some event
elsewhere.
Still Stumped
Andi
> Hi Andi,
>
[quoted text clipped - 21 lines]
>
> For more, see Help, or
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/ac
evtKeyDown_HV03079790.asp
> >I am having problems being able to track when CTRL and C are pressed at the
> >same time. I have added the following to the keydown event of my Flexgrid
[quoted text clipped - 19 lines]
>
> Please respond in the newgroup and not by email.
John Nurick - 28 Feb 2006 21:26 GMT
I dunno. I've never used a Flexgrid, but Ctrl-C, Ctrl+X and Ctrl-V are
pretty suggestive: sounds like something is intercepting the clipboard
shortcuts before the keystroke is passed to the Flexgrid. Does the
active cell (or whatever it's called) of the Flexgrid have its own
keystroke events?
One thing that's worth trying is to set the Form's KeyPreview property
to True, and see if you can pick up these keystrokes in the Form's
keypress event. That should short-circuit any funny business with the
Flexgrid.
>Hi John - Thanks for your suggestion but unfortunately it didn't work form
>me.
[quoted text clipped - 67 lines]
>>
>> Please respond in the newgroup and not by email.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.