[AccessD] Capturing the application's Close event

John W. Colby jcolby at colbyconsulting.com
Thu Dec 4 10:33:45 CST 2003


Nope, all the others can close because there is nothing to prevent them from
closing.  The one that can't close will fail to close and the database will
stay open.

Of course you touch on a point, everything except this form (and the
database itself) WILL close, so any open forms, reports, menu form etc will
close.  What I do (yes, I use this technique) is actually allow the form to
close, but before it closes I call my cleanup code which closes all open
objects such as classes, recordsets etc.  IOW, I just do cleanup, then go
ahead and allow the close.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Garraway, Alun
Sent: Thursday, December 04, 2003 11:22 AM
To: Access Developers discussion and problem solving
Subject: AW: [AccessD] Capturing the application's Close event


I think the hidden form must also be the first you open,
because Access closes the forms in the order they opened when shutting down.

alun

-----Ursprüngliche Nachricht-----
Von: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]Im Auftrag von John W.
Colby
Gesendet: Donnerstag, 4. Dezember 2003 17:08
An: Access Developers discussion and problem solving
Betreff: RE: [AccessD] Capturing the application's Close event



One way to do this is to:

1) Create a global blnAllowClose
2) Open a form hidden.
3) In the form OnClose place a

	Cancel = blnAllowClose

4) Set blnAllowClose = false when the form opens.
5) In your app, in the button or whatever you use to close the database, set
blnAllowClose = true

It turns out that Access can't close when an object remains open.  By
setting up the hidden form and not allowing it to close until your global
variable says it can, you have effectively prevented the form from closing,
which prevents ACCESS from closing.

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Christopher
Hawkins
Sent: Thursday, December 04, 2003 10:59 AM
To: accessd at databaseadvisors.com
Subject: [AccessD] Capturing the application's Close event


Hola!

I have inherited an Access application (those words alone should
alert you that nothing good is going to follow in this message) that
is exhibiting strange behavior when the user exits by clicking the
Close button on the Access shell.

I'd like to be able to capture and stop the Close process when the
user attempts to exit this way.  I have Googled, but to no avail.

Anyone know how to do this?

-Christopher-


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list