Application unload event

W

Warrio

Hello,

as for a form, does an unload event exist for the hole access database?
an event that occurs when the user clicks on the main application cross
button.

Thanks in advance!
 
D

Dirk Goldgar

Warrio said:
Hello,

as for a form, does an unload event exist for the hole access
database? an event that occurs when the user clicks on the main
application cross button.

No, there's no such event, or at least, not exposed where we programmers
can get at it. What people generally do is create a form that they keep
open but hidden the entire time the database is open. When the database
closes, that form's Unload event will fire, followed by its Close event.
So you can put code in one of those events, treating it as the
"Application Unload" event. If you need to be able to stop the
application from closing, you must use the form's Unload event, because
you can cancel that event to keep the database open.
 
G

Graham Mandeno

No, but the common workaround is to open a hidden form when the database
opens and create an Unload event procedure for this form. All forms must be
closed before the Access application terminates, so if any open form cancels
its Unload event, nothing happens and the application stays open.
 
W

Warrio

thanks for your answers, but the thing is that I have forms that never close
unless the user decide to close the hole application. and one form should
close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


Graham Mandeno said:
No, but the common workaround is to open a hidden form when the database
opens and create an Unload event procedure for this form. All forms must
be closed before the Access application terminates, so if any open form
cancels its Unload event, nothing happens and the application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Warrio said:
Hello,

as for a form, does an unload event exist for the hole access database?
an event that occurs when the user clicks on the main application cross
button.

Thanks in advance!
 
A

Andreas

May be you could use the 2nd form's Unload event to close the 1st form,
depending on what it is you are trying to do.

Regards,
Andreas

thanks for your answers, but the thing is that I have forms that never close
unless the user decide to close the hole application. and one form should
close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


No, but the common workaround is to open a hidden form when the database
opens and create an Unload event procedure for this form. All forms must
be closed before the Access application terminates, so if any open form
cancels its Unload event, nothing happens and the application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hello,

as for a form, does an unload event exist for the hole access database?
an event that occurs when the user clicks on the main application cross
button.

Thanks in advance!
 
W

Warrio

is there an order on which access closes the forms?
is by the form who has the focus?, is it the form's name? is it the 1st
loaded?.... or is it just random??

Thanks

Andreas said:
May be you could use the 2nd form's Unload event to close the 1st form,
depending on what it is you are trying to do.

Regards,
Andreas

thanks for your answers, but the thing is that I have forms that never
close unless the user decide to close the hole application. and one form
should close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


No, but the common workaround is to open a hidden form when the database
opens and create an Unload event procedure for this form. All forms must
be closed before the Access application terminates, so if any open form
cancels its Unload event, nothing happens and the application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Hello,

as for a form, does an unload event exist for the hole access database?
an event that occurs when the user clicks on the main application cross
button.

Thanks in advance!
 
A

Andreas

As far as I am aware, the last form opened is the first form to close.

Regards,
Andreas

is there an order on which access closes the forms?
is by the form who has the focus?, is it the form's name? is it the 1st
loaded?.... or is it just random??

Thanks

May be you could use the 2nd form's Unload event to close the 1st form,
depending on what it is you are trying to do.

Regards,
Andreas

thanks for your answers, but the thing is that I have forms that never
close unless the user decide to close the hole application. and one form
should close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


"Graham Mandeno" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...


No, but the common workaround is to open a hidden form when the database
opens and create an Unload event procedure for this form. All forms must
be closed before the Access application terminates, so if any open form
cancels its Unload event, nothing happens and the application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Hello,

as for a form, does an unload event exist for the hole access database?
an event that occurs when the user clicks on the main application cross
button.

Thanks in advance!
 
A

Andreas

Hit the "reply" button too quickly.
Basically the forms close in reverse order to being opened.

Regards,
Andreas

As far as I am aware, the last form opened is the first form to close.

Regards,
Andreas

is there an order on which access closes the forms?
is by the form who has the focus?, is it the form's name? is it the
1st loaded?.... or is it just random??

Thanks

May be you could use the 2nd form's Unload event to close the 1st
form, depending on what it is you are trying to do.

Regards,
Andreas


Warrio wrote:

thanks for your answers, but the thing is that I have forms that
never close unless the user decide to close the hole application.
and one form should close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


"Graham Mandeno" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...


No, but the common workaround is to open a hidden form when the
database opens and create an Unload event procedure for this form.
All forms must be closed before the Access application terminates,
so if any open form cancels its Unload event, nothing happens and
the application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Hello,

as for a form, does an unload event exist for the hole access
database?
an event that occurs when the user clicks on the main application
cross button.

Thanks in advance!
 
W

Warrio

Thanks for the replies!!
but it's first in, first out!
I tried, and it works perfectly, thanks again!! and nice weekend

Andreas said:
Hit the "reply" button too quickly.
Basically the forms close in reverse order to being opened.

Regards,
Andreas

As far as I am aware, the last form opened is the first form to close.

Regards,
Andreas

is there an order on which access closes the forms?
is by the form who has the focus?, is it the form's name? is it the 1st
loaded?.... or is it just random??

Thanks

"Andreas" <[email protected]> a écrit dans le message de (e-mail address removed)...

May be you could use the 2nd form's Unload event to close the 1st form,
depending on what it is you are trying to do.

Regards,
Andreas


Warrio wrote:

thanks for your answers, but the thing is that I have forms that never
close unless the user decide to close the hole application. and one
form should close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


"Graham Mandeno" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...


No, but the common workaround is to open a hidden form when the
database opens and create an Unload event procedure for this form.
All forms must be closed before the Access application terminates, so
if any open form cancels its Unload event, nothing happens and the
application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Hello,

as for a form, does an unload event exist for the hole access
database?
an event that occurs when the user clicks on the main application
cross button.

Thanks in advance!
 
M

MarkInSalemOR

Too funny this question gets asked the same day I need the answer. Thanks to
all.

One thing I've done is setup a close function in a module and then I call
that function from all form unload events. That gives me the opportunity to
close connections I have to a DB2 database. When I need exact control of
what forms are open I don't use DoCmd to open them. Instead I declare them as
variables and open them explicitly. That way when the parent object is closed
the forms are closed, they go out of context when the parent closes.

Pulbic fMyForm as Form_frmMyForm 'declare public or private based on what
you want to have access to it.
Set fMyForm = New Form_frmMyForm

Doing it that way if you need certain things to happen when a form is open
you don't have to go searching for it.
if not fMyForm is nothing then 'if it's not nothing it exists
'do whatever needs to be done
'if you're closing fMyForm then
set fMyForm = Nothing 'and away it goes
end if

One caution with this procedure you can go in and debug in forms created
this way but any code you write will not save, in Access 2000. I don't know
if later versions of Access have dealt with that issue.

I did this since I have an application where one form has daughters and I
risk data integrity problems if a daughter form is left in existance. Since
the daughter forms are declared and created in the parent form, when the
parent form goes out of context the daughter forms have to go away. I have
not tested the impact of a cancel in the unload event of a daughter form. Oh
and all forms are daughters of my apps main form so if it closes either by
user action or the application is closed it all closes.

~Mark

Warrio said:
Thanks for the replies!!
but it's first in, first out!
I tried, and it works perfectly, thanks again!! and nice weekend

Andreas said:
Hit the "reply" button too quickly.
Basically the forms close in reverse order to being opened.

Regards,
Andreas

As far as I am aware, the last form opened is the first form to close.

Regards,
Andreas


Warrio wrote:

is there an order on which access closes the forms?
is by the form who has the focus?, is it the form's name? is it the 1st
loaded?.... or is it just random??

Thanks

"Andreas" <[email protected]> a écrit dans le message de (e-mail address removed)...

May be you could use the 2nd form's Unload event to close the 1st form,
depending on what it is you are trying to do.

Regards,
Andreas


Warrio wrote:

thanks for your answers, but the thing is that I have forms that never
close unless the user decide to close the hole application. and one
form should close only if the 1st window is closed.
and unfortunately the unload event goes first to the 2nd form.

how can I make it go to the 1st form unload event?

Thanks again


"Graham Mandeno" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...


No, but the common workaround is to open a hidden form when the
database opens and create an Unload event procedure for this form.
All forms must be closed before the Access application terminates, so
if any open form cancels its Unload event, nothing happens and the
application stays open.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Hello,

as for a form, does an unload event exist for the hole access
database?
an event that occurs when the user clicks on the main application
cross button.

Thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top