Disable the Function Keys

georget

Registered User.
Local time
Today, 08:57
Joined
Jul 17, 2002
Messages
31
I'm using Access 2002.

How do I disable the F1 - F12 Keys?

Thanks
 
1. leaver off function key buttons with screw-driver
2. Put a small blob of super-glue at base of each key
3. Allow glue to harden
4. Replace buttons

voila! Function Keys disabled
 
Create a macro called "AutoKeys" without the quotes.

In Design do the following.
Macro Name {F1} Action CancelEvent

So forth and So forth, but I agree the previous method works more efficiently.

Dave
 
With the marco I got F2 disabled but now I cannot get it back!

I have closed the program and later shut down the computer but I can no longer F2 around.

How do I enable F2 again?

Access is XP version.
 
If I could, I'd rathere do this in VBA instead of a macro.
 
You can use the "forms" Key Down event to detect if a trapped key is pressed and then override that keys normal function with another action or just exit the sub. Below is an example of the forms Key Down event where I am using a Case Select to trap specific key presses. Check the help files for the Keycode Constants to get the codes for all keys.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        
    Select Case KeyCode
        Case vbKeyDelete
            MsgBox "The Delete key was Pressed"
        Case vbKeyF1
            MsgBox "The F1 key was Pressed"
        Case vbKeyF2
            MsgBox "The F2 key was Pressed"
        Case Else
            'MsgBox "No match!" 'testing
    End Select
    
End Sub
Just REM out the message boxes when you are ready to go live. Then nothing will happen when the trapped keys are pressed. Turning this into a public function would be nice if that were possible.

HTH
 
I am using Access XP on a Win2000 PC

ghudson,

I did as you said, rechecked the work about 3 times. I cannot get a message response clicking anywhere on the form.

I added the case structure to a control's OnKeyDown and got the messages.

All I have on the form is a listbox, subform and many command buttons. Is the OnKeyDown event supposed to handle all controls on the form?

I must be doing something wrong but I do not know what.
 
gHudson,

I added the case structure above to the textbox on the subform.

For F2 I had the following Select statement:

Case vbkeyF2
Msgbox "The F2 keywas pressed"
exit sub
End select

But this does not keep the F2 from functioning. I get the message but the control is alternately going from fully highlithted to cursor at beginning of text not highlighted.

Interesting stuff if I could get my arms around it!:rolleyes:
 
I forgot two very important parts. 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:
'The forms Key Preview property must be set to Yes
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
    Select Case KeyCode
        Case vbKeyDelete
            MsgBox "The Delete key was Pressed"
            KeyCode = 0
        Case vbKeyF1
            MsgBox "The F1 key was Pressed"
            KeyCode = 0
        Case vbKeyF2
            MsgBox "The F2 key was Pressed"
            KeyCode = 0
        Case Else
            'MsgBox "No match!" 'testing
    End Select
        
End Sub
Just REM out the message boxes when you are ready to go live.

HTH
 

Users who are viewing this thread

Back
Top Bottom