Monday, July 20, 2015

Disable Alt + F4

Set the "Key Preview" property of the form to Yes.

Now use the Form's "On Key Down" event to do what you ask:


Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intAltDown As Integer
intAltDown = (Shift And acAltMask) > 0

Select Case KeyCode
  Case vbKeyF4
    If intAltDown Then
      KeyCode = 0
      MsgBox "Alt+F4 has beed Disabled.", vbExclamation + vbOKOnly, " Disabled Key"
    End If
End Select
End Sub
HTH
RDH