Solved Disable keyboard close in a form (1 Viewer)

zelarra821

Registered User.
Local time
Today, 05:23
Joined
Jan 14, 2019
Messages
818
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.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:23
Joined
Oct 29, 2018
Messages
21,619
You could try setting the form's Key Preview to Yes and then put code in the Key Up event.
 

zelarra821

Registered User.
Local time
Today, 05:23
Joined
Jan 14, 2019
Messages
818
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.
 

zelarra821

Registered User.
Local time
Today, 05:23
Joined
Jan 14, 2019
Messages
818
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.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:23
Joined
Oct 29, 2018
Messages
21,619
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

Top Bottom