Disabling Alt + F4 on a form? (1 Viewer)

Bee*

Registered User.
Local time
Yesterday, 19:38
Joined
Aug 22, 2007
Messages
12
Hello again, sorry for creating a new thread so soon.

My form contains only 3 buttons and has no control box so that users cannot close it. The purpose of the database is to record their login and logout times when they start and close windows. As the db needs to remain open up until they leave, I need the form to be close proof (except for going in task manager, can't stop that) which means attempting to disable Alt + F4.

Any way I can do this?

Thanks.
 

missinglinq

AWF VIP
Local time
Yesterday, 22:38
Joined
Jun 20, 2003
Messages
6,420
In Form Design View, set the KeyPreview Property to YES, then use this code
Code:
Private Sub Form_keydown(KeyCode As Integer, Shift As Integer)
 If Shift = acAltMask And KeyCode = vbKeyF4 Then
  KeyCode = 0
 End If 
End Sub
I assume you plan on closing the Form down at some point; how are you going to do that? Most users don't realize that you can add a Label to a Form and place code in its OnClick event. That's an approach I've used for years to do something like this.

Linq ;0)>
 

Bee*

Registered User.
Local time
Yesterday, 19:38
Joined
Aug 22, 2007
Messages
12
Thanks very much for that code, works a charm.

The database automatically opens when the user logs in in the morning and records their log in time (on Form_Open sub). Then when they shut windows down last thing at night, the database will automatically close and records a log out time too (on Form_Close sub).
 

Users who are viewing this thread

Top Bottom