Full screen form - How to prevent closing it (ALT + F4...)?

MrNooby

Registered User.
Local time
Today, 23:44
Joined
Feb 21, 2010
Messages
58
When someone opens my application it's full screen. All fine, except the problem is when someone clicks ALT + F4 this forms closes and all tables, forms,... are seen which confuses some of my experienced users. How can I disable that they will close form with CTRL + F4 and if there's any other command which causes form to close? I tried to use on key down in form event but it doesn't react, only if I use the code on some text box, not in form itself.
 
This is not something that you can control in Access. The use of Alt + f4 is defined by Windows and will close the active applicaiton.
 
In Access 2003 one of the things that I frequently do is go to

Tools

Startup

and then untick the Show Database Window

That way on startup even if they manage to close the form they are in they shouldn't be able to see the forms tables or queries.
 
ALT + F4 doesn't close my application, it just closes the form, that's the problem.
 
Why are they hitting alt+f4 in the first place? IF they get confused when they do it, tell them to stop using it!!
 
When it comes to end user it's best to limit to whatever he needs. That's why I would like to limit this in code. I don't like if users wonder to the "back-end" and do changes on their own (messing up things which needs to be fixed later).

The best thing would be if anyone enters ALT + F4 or any other key combination which closes form or shows "back-end" to ask for some password which only I would have...
 
ALT + F4 doesn't close my application, it just closes the form, that's the problem.
The behaviour os ALT+F4 is to close the application as Mr. B said. Unless, you've programmed the keys to do otherwise.

If you can stop the form from closing when the key is pressed, then you can intterupt the application from closing.
 
I noticed I had Keypreview to OFF, I turned it to ON and now form is reading keys.

All I have to figure out is now why this doesn't work:
Code:
If KeyAscii = vbKeyF4 Then
 
On the Key Down event?

I would imagine you need to test for a combination of keys too, not just F4.
 
Hi
When you have a form open and maximized with the property pop-up active, the behavior of the ALT + F4 is closing the form. This is correct.

has two alternatives:

1) Use the event to "unload"

-create a variable in the form module:

public booExit as Boolean

- In the event "unload"

Private Sub Form_Unload (Cancel As Integer)
If booExit = False Then Cancel = True
End Sub

In the event of the button exit:

booExit = true

The program closes only the exit button

2) In the event of the form "KeyDown"

Private Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
If KeyCode = 115 Then KeyCode = 0
End Sub

Activate the view key proprieadade

Success
 
I now used

Code:
If Shift = 4 And KeyCode = 115 Then
and success :)

This way I can close down the entire application instead of just form.



I now thought of something else... That I would add code to "on close" form event the password check, so this will be even better. I managed to do this but there's just one problem. I have 1 button to close application with "Quit" but now when I click this button I'm also asked for password, how to exclude this?
 
Last edited:
Set a Database password if you so wish. Access has this as a built-in feature. Check through the menus.
 
In the event "to close" will not work because if the password is wrong the event does not have the cancel mechanism.

Use the event "unload"

Private Sub Form_Unload (Cancel As Integer)
Dim pwd
pwd = InputBox ( "Enter Password", "password")
If pwd = "xyz" Then

Else
Cancel = True
End If
End Sub
 
Thanks, for now I just disabled CTRL and ALT key because I found out that there's other keys which are messing around like CTRL + G gives me VBA code,... Shift doesn't contain any shortcut right?
 
If you hold shift on startup you can get into the forms/tables etc... you can disable that in the startup options though
 

Users who are viewing this thread

Back
Top Bottom