Disable Shortcut key

accessman2

Registered User.
Local time
Today, 13:22
Joined
Sep 15, 2005
Messages
335
Hi:

Does anybody know how to disable shortcut key, such as Alt+Enter....? I am creating a database application, I don't want user to use shortcut key to do his stuff. How can I lock/disable shortcut key?

Please let you know, thanks.
 
Set the Key Preview property of your form to Yes.

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  
  Select Case KeyCode
    Case 13, 18
       KeyCode = 0
  End Select
  
End Sub

Look up Keycode in Help for more info...

Regards,
Tim
 
Set the Key Preview property of your form to Yes.

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  
  Select Case KeyCode
    Case 13, 18
       KeyCode = 0
  End Select
  
End Sub

Look up Keycode in Help for more info...

Regards,
Tim

Tim:

This is a pretty good idea but this approach would first trap the ALT and then the ENTER. That would disable the ability to press Enter on the form which would probably not be a good idea.

Do you know of a way to trap the combination rather than the individual keystrokes?

SHADOW
 
Code:
    If Shift = 4 Then               'Alt key
        Select Case KeyCode
            Case vbKeyReturn
                KeyCode = 0
        End Select
    End If
 
Code:
    If Shift = 4 Then               'Alt key
        Select Case KeyCode
            Case vbKeyReturn
                KeyCode = 0
        End Select
    End If

Perfect! That's just what I was looking for. I wanted to disable CTRL + '. The shift code for CTRL is 2 so your solution was helpful.

Thanks a lot

SHADOW
 

Users who are viewing this thread

Back
Top Bottom