Solved Disable keyboard close in a form

zelarra821

Registered User.
Local time
Tomorrow, 00:35
Joined
Jan 14, 2019
Messages
835
Good afternoon. I have a question. I usually close the forms with Control + W, but sometimes I freak out, and I end up closing the main form, and I have to restart the database (I usually remove the navigation panel, and, come on, everything, to leave it as an application , and that Access is not visible). So I wanted to know if it is possible to disable this functionality from VBA in a specific form. Thanks a lot.
 
You could try setting the form's Key Preview to Yes and then put code in the Key Up event.
 
Voucher. I have already set that option to Yes. What code do I have to put? I do not know how to do it. Thanks a lot.
 
I have achieved it. It has been to activate the option that you have told me and the following code:

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Shift = acCtrlMask And KeyCode = vbKeyW Then KeyCode = 0
End Sub

Thanks a lot. Happy new year.
 
I have achieved it. It has been to activate the option that you have told me and the following code:

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Shift = acCtrlMask And KeyCode = vbKeyW Then KeyCode = 0
End Sub

Thanks a lot. Happy new year.
Glad to hear you got it sorted out. Happy New Year!
 

Users who are viewing this thread

Back
Top Bottom