"F1 key" Press

richardn

Registered User.
Local time
Today, 06:46
Joined
Nov 6, 2001
Messages
49
How to catch the "F1 key" Press event ? (from a form)
Thanks
 
Code:
    If KeyCode = 112 Then
        KeyCode = 0
        [i]Do Your Stuff Here[/i]
    End If
 
Try searching the acces help using "Autokeys"

Regards

Mile: The key press event dont work on "autokeys"
 
I would use the forms KeyDown event. There might be a more global way of doing this. The AutoKeys macro would do it but some people have problems with it. That said, here is how to set up the KeyDown event for each form using Access 97.

The forms Key Preview property must be set to Yes and the KeyCode must be = 0 to prevent that keys normal function from happening, when pressed!

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
    Select Case KeyCode
        Case vbKeyF1
            KeyCode = 0
            MsgBox "The F1 key was Pressed"
        Case vbKeyF2
            KeyCode = 0
            MsgBox "The F2 key was Pressed"
        Case Else
            'MsgBox "No match!" 'testing
    End Select
        
End Sub
Just remove what you do not need.

HTH
 
On key down does seem to work... :) Learned something today :)

Regards
 

Users who are viewing this thread

Back
Top Bottom