Properly closing an Access database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I recently created a database and installed buttons to properly close the
database to avoid coruption of files etc. However I could not find a way to
eliminate the X button in the upper right corner of access. Today my dbase
crashed, I presume because someone did not use the buttons I installed, and
just closed using the X in the upper right corner of access. The database is
on a network, and was not password protected at the time. It will be when it
is restored, however I would still like to know if there is a way to
eliminate the x button in the upper right hand corner so that users will have
to use the buttons created to properly close the database.
 
I'm not sure about hiding the close button in the main Access window, but
you can hide the main Access window altogether, and you can hide the close
button in your forms. There's code to do both of these things in the API
section at www.mvps.org/access

However, I'm not sure that this will solve your problem. It is unlikely that
users clicking the Access close button is the source of your problem, it is
more likely to be caused by users switching off the computer without closing
Access at all, and there is no programmatic way of dealing with that. (Yes
you can do all kinds of clever tricks, but at the end of the day if the user
is irresponsible or frustrated enough to pull the plug, it will take more
than code to solve that problem).

If there is something you really want to happen when your form closes, put
it in the Unload or Close event of your form. Then it will happen regardless
of whether the user clicks your custom close button or the built-in close
buttons or presses Alt + F4 or whatever.
 
When the database opens, open a form (it can be hidden if you like) that
will be left open for the entire time the database is open.

In that form's Unload event, put logic that sets Cancel = True unless some
condition that you set in your "proper" close button is met (say, setting a
global variable to True)
 
I've never seen a problem with someone closing a database by using the X
button for the Access program.

I have seen problems with people just shutting off the power button on their
computers or having a power outage. Neither of these can be fixed with code
except for code that does frequent backups. A UPS on each computer plus the
server can minimize the problems with power outages.
 

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

Back
Top