When my users are using the Access application, some of them might exit the application by clicking on the Close button on the top right. How can I disable this button and let the users exit the application gracefully?
I think you're talking about the main window's close box, not a form's.
My method is somewhat like the FAQ RoyVidar mentioned. I open a hidden, empty form when the application starts up. This form has a Close event that calls my graceful shutdown code.
Rick Sprague
Want the best answers? See faq181-2886 To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
Rick was right. I'm talking about the main window's close box, not the one on the form. I want to remove the 'x' for the application itself in the upper right corner. How can I make API calls to do it???
Thanx - yeah the simplicity and efficiency of it is something I really like!
Removing the x is mainly a visual thingie, and will not disable for instance ALT+F4, CTRL+F4, CTRL+W and other means of closing the app/last form on the app, which you'll probably also need to do. thread702-831433 has one suggestion and a link to a Microsoft solution.
Here's an alternative which effectively disables the close box, as well as Alt+F4, Ctrl+F4, etc. It even prevents shutting down Windows or using the Task Manager to kill Access.
When the application starts, open a hidden, empty form which has the following in its Unload event procedure:
Code:
Cancel = True
MsgBox "Please use the 'Exit' button to end the application"
This avoids the messy API calls.
Rick Sprague
Want the best answers? See faq181-2886 To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.