KeyCode

G

Guest

I have this on the KeyDown event of the form:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 112 Then KeyCode = 0
End Sub

So if the user hits the F1 key it does not go to help.

Is there a way to catdh the Ctrl+?? to basically control any Ctrl + key
combination.
for example:

If KeyCode = Ctrl+Break then KeyCode = 0

Can this be done somehow?

Thank you for your help.

Steven
 
B

Brendan Reynolds

You need to use the second, 'Shift' argument to detect the Control key ...

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)

If (Shift And acCtrlMask) And KeyCode = vbKeyA Then
MsgBox "You pressed Ctl + A"
End If

End Sub
 
G

Guest

Thank you for your responses:

I still can't seem to get to the ultimate goal.

I want to catch the Ctrl-Break on certain forms and have the system ignore
the Ctrl-Break keypress and continue with the process.

How can I do this?

Thank you,

Steven
 
B

Brendan Reynolds

I'm not sure about this, but it may be that you can't do that
programmatically. Ctrl+Break is used to interrupt running code, so it may be
that VBA checks for the Ctrl+Break key combination before your code runs,
making it impossible to trap that combination programmatically.

Try unchecking the 'Allow Access Special Keys' option in the 'Startup'
dialog box. (You'll have to close and re-open the MDB for the change to take
effect.)
 

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