Article ID: 245746 - Last Review: June 23, 2005 - Revision: 3.0 ACC2000: How to Disable the Close Button (X) on the Access Application WindowThis article was previously published under Q245746 Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp). On This PageSUMMARY
Microsoft Access has no built-in method for disabling the Close button (X) on the application window or the Close command on the System menu of the application window. This article describes how to programmatically disable both of these.
MORE INFORMATION
In order to disable the application Close button and the Close command on the System menu, you must call the GetSystemMenu and ModifyMenu functions from the Win32 API. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Step-by-Step Example
UsageThe CloseCommand class module described in this article allows you to easily enable or disable the Close button and the Close command of the application window. The class module also allows you to check the state of these commands to determine if they are currently enabled or disabled. Before doing either of these, your code must first create an instance of the CloseCommand class, as demonstrated in the InitApplication function earlier in this article.To check the state of the Close button, refer to the Enabled property of the CloseCommand instance that your code created. Likewise, to set the state of the Close button, assign True or False to the Enabled property of the CloseCommand instance that your code created. Please note that this technique affects the Close button on the application window of Microsoft Access, not the Close button on the Database window. After disabling the Close button, the button is not automatically reenabled when your database closes. If the user closes the database and leaves Microsoft Access open, the user will not be able to quit Microsoft Access by using the Close button. In this case, your application should reenable the Close button before it terminates. Otherwise, the user will have to quit and restart Microsoft Access in order for the Close button to be enabled. This technique does not disable the Exit command on the File menu. If your application needs to disable this command, you must customize the File menu to remove the Exit command. | Article Translations
|
Back to the top
