Events as the DB closes

P

Pastor Del

I build an application that controls the visibility of command bars while it
is open. The command bars are restored to the user's previous settings when
the application is closed with the Close button I provided . The problem is
that some users are in the habit of closing the DB with the X in the upper
right corner or with alt/F4. This obviously by-passes my code. I've tried
opening and hiding a form when the DB opens and putting my command bar code
in the Form_Close event to restore them when the DB closes. This seems to be
an unreliable method. To improve performance I moved the code to the
Form_Unload event. It works better but I don't have the confidence factor
I'd like to have.

Here's my question. What is a reliable way to ensure code is executed when
the DB is closed?
 
M

Marshall Barton

Pastor said:
I build an application that controls the visibility of command bars while it
is open. The command bars are restored to the user's previous settings when
the application is closed with the Close button I provided . The problem is
that some users are in the habit of closing the DB with the X in the upper
right corner or with alt/F4. This obviously by-passes my code. I've tried
opening and hiding a form when the DB opens and putting my command bar code
in the Form_Close event to restore them when the DB closes. This seems to be
an unreliable method. To improve performance I moved the code to the
Form_Unload event. It works better but I don't have the confidence factor
I'd like to have.

Here's my question. What is a reliable way to ensure code is executed when
the DB is closed?


The Unload event in an always open form is the recommended
way to do that kind of thing.
 
D

David C. Holley

However, it does not guarantee tha the events will fire. There are ways that
Access can terminate abnormally which can be forced by the user.
 
C

ChrisO

I think if you require reliability for this you would need to store a list of
Command Bars in a table and re-instate them at start-up not shut-down.
 
M

Marshall Barton

That is reliable when the application is closed. You now
seem to be concerned with abnormal termininations of Access
such as power failures or system crashes. There is no way
to run an event of any kind in these situations.

To be sure that thing are set the way you want when your
applcation is started, then Chris is right about using code
in the startup form.
 

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