Prevent USe of Outer "X" to Close Access 2013

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
I'm completing an application (written using Access 2013) and I need to prevent the user from inadvertently selecting the outer "X" on the screens - which immediately Exits the Program. I find numerous articles googling, but each one seems to go on and on,,
so after 2 to 3 pages of complex error-handling pages I'm lost. Is there a simple - cut and dried (the short version) method?

TIA, Jim
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I'm completing an application (written using Access 2013) and I need to prevent the user from inadvertently selecting the outer "X" on the screens - which immediately Exits the Program. I find numerous articles googling, but each one seems to go on and on,,
so after 2 to 3 pages of complex error-handling pages I'm lost. Is there a simple - cut and dried (the short version) method?

TIA, Jim

Jim, do you have something in terms of a switchboard that you had built for your users to navigate? If you did you can try using this below. It utilizes the unload event on a hidden form that runs when users close out of the application itself. Just make sure you have a way to exit the application if programming this in.
General: Prevent Access from closing

The other workaround is from the Microsoft article itself but that's a bit more technical. (Close button (X) on the application window or the Close command on the System menu of the application window)
http://support.microsoft.com/kb/245746
 
Upvote 0
Terry - Thanks.

Your references look familiar, but I will certainly follow them. One quick Q - which confused me before (and is repeated above).. I understand the Close button (X) on the application window (What I refer to as the Outer "X"),
but I'm unsure of what is meant by the Close command on the System menu -- unless this means (In My Task Bar I see the Access Icon, and I know (like any program down there - I can right-click on it an The CLOSE option is available.. - Is this what they are referring to?

Thanks Again,, Jim
 
Upvote 0
Terry,

In setting this DB up I did so on my Laptop (running Access 2013 64-Bit)

My Client (I just learned) runs Access 2013 32-Bit. Does this matter for any reason, or in the case of dealing with the Close issue involved here?

regards,

Jim
 
Upvote 0
Terry,

In setting this DB up I did so on my Laptop (running Access 2013 64-Bit)

My Client (I just learned) runs Access 2013 32-Bit. Does this matter for any reason, or in the case of dealing with the Close issue involved here?

regards,

Jim

Pretty sure it's mainly related to RAM usage in 32-bit vs 64-bit but check below further on the deployment. I think most stuff works when going from a 32-bit machine to 64-bit, but not sure about the other way around.
UtterAccess Microsoft Access Help Forums and Wiki 32bit Access vs 64bit Access - UtterAccess Discussion Forums

I don't have a 64-bit install so I can't comment too much about it. You may want to test out a few things to ensure that the functionality works for the DB. Some of the variables types seem to change as well, for your reference below.
http://msdn.microsoft.com/en-us/library/ee691831(office.14).aspx

To your question on the closing, you are right it is the outer top right (X) as well as right click close application in the taskbar.

The website with the original post I had works for both situations.
 
Last edited:
Upvote 0
On my SwitchBoard I have a command button "Quit Application" with an Embedded Macro with simply Quit Access - Prompt (no change to it)

I do not want to have to use the suggested "hfromCloseAccess" form if I don't have to.

So now, so far I've done the following:

I inserted a new module2 and pasted in:

Option Compare Database
Option Explicit

Public pboolCloseAccess As Boolean

========================================

Behind my frmStartUp (In the VBE) I have:

Private Sub Form_Open(Cancel as Integer)
pboolCloseAccess = False
End Sub

and also

Private Sub Form_Unload(Cancel As Integer) 'the instructions say to set the variable to true "and also check for its value" ?????
'I understand the set var to true (the next line), but not also check for its value...
pboolCloseAccess = True
'
< < Neither do I understand if I need to enter the DoCmd.Close acForm, "hfrmCloseAccess" < < since I've chosen not to use it
Same for the docmd.Quit since my command button "Quit Application" takes care of that.
End Sub

========================================

In the Article there is mention of having an AutoExec Macro - but it seems to relate to the hfrmCloseAccess. Do I need to create an AutoExec -- I'm currently using under File Options: Current DB - Display Form: frmStartup

So, I'm back to where I was before, getting a bit confused with the do's and don'ts.

Can you assist?

TIA,

Jim
 
Upvote 0
It's basically checking if the form is hidden or not, then running the check to see if it is and exiting all together if true.

If you aren't going to do the hidden form approach you will need to always have the switchboard open and modify it to suit your needs.

I went with the hidden form approach, so here is the objects that I have.

A Module in the VBE with

Code:
 Option Compare Database

Public pboolCloseAccess As Boolean

A form entitled - hfrmcloseaccess
The code on this form below
Code:
Private Sub Form_Unload(Cancel As Integer)
'Trigger the unload when this form is still open
'This prevents users from exiting the application with the
'closes(X) on the top right itself
If Not pboolCloseAccess Then Cancel = True
End Sub

Private Sub Form_Open(Cancel As Integer)
'Makes the public function pboolCloseAccess as false
pboolCloseAccess = False
  
End Sub

a Macro entitled AutoExec with
1) Open form hfrmCloseAccess with Hidden in the Window Mode
2) Open form whateveryourform is with the exit button with Normal in the Window Mode

You don't need to set the form to auto open to whatever in the options, let the macro do that (above)

So now you technically have both forms opens with one hidden, the form open event would trigger and set the boolean and the code would fire to prevent you from exiting through top right x or right click on taskbar and close since the form is open.
 
Last edited:
Upvote 0
Terry,

Thank you so very much for providing the detail necessary for me to accomplish this task. It is much appreciated.


Jim
 
Upvote 0

Forum statistics

Threads
1,215,844
Messages
6,127,252
Members
449,372
Latest member
charlottedv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top