How to close a database?

S

Shadow

When an Access databae is opened, there's a X button at the top right of the
window. ( just like every other application or window). Is there anyway to
run a macro/sub/function when this X button is clicked?
If not, is there any way to hide this button?

In Excell we can create a sub in workbook objects's on-close event. Is there
any way to do the same task in Access?

Any kind of help is much appreciated.

I need to oblige the users to click a button in a form to close the
database.

Ghalamkari
 
W

Wayne Morgan

When you open the database, open a hidden form (Visible=No). In this form's Unload event check for the value of a "flag" variable. If the value isn't what was expected, set Cancel=True and pop-up a message to the user. You would set the value of this "flag" variable in the OnClick event of your close button. You would declare the variable in a standard module as a Public variable so that it can be used anywhere in the database.

Depending on what you're doing in your close button's routine, you may be able to perform the same items in the unload event of this hidden form instead of insisting on the user using your close button.

--
Wayne Morgan
Microsoft Access MVP


When an Access databae is opened, there's a X button at the top right of the window. ( just like every other application or window). Is there anyway to run a macro/sub/function when this X button is clicked?
If not, is there any way to hide this button?

In Excell we can create a sub in workbook objects's on-close event. Is there any way to do the same task in Access?

Any kind of help is much appreciated.

I need to oblige the users to click a button in a form to close the database.

Ghalamkari
 
E

Ed Robichaud

All Access forms have many format properties that you can set. These include whether to display the min/max/close buttons, the control box, scroll bars, record nav buttons, etc. One of the more common ways to control the user interface is to select having the close button and control box not display, then using a command button that will run the "close form" statement and any other code you need to run on shutdown.

-Ed

When an Access databae is opened, there's a X button at the top right of the window. ( just like every other application or window). Is there anyway to run a macro/sub/function when this X button is clicked?
If not, is there any way to hide this button?

In Excell we can create a sub in workbook objects's on-close event. Is there any way to do the same task in Access?

Any kind of help is much appreciated.

I need to oblige the users to click a button in a form to close the database.

Ghalamkari
 
S

Shadow

thanks for your help
exactly what I was looking for



with regards
Shadow


message When you open the database, open a hidden form (Visible=No). In this
form's Unload event check for the value of a "flag" variable. If the value
isn't what was expected, set Cancel=True and pop-up a message to the user.
You would set the value of this "flag" variable in the OnClick event of your
close button. You would declare the variable in a standard module as a
Public variable so that it can be used anywhere in the database.

Depending on what you're doing in your close button's routine, you may be
able to perform the same items in the unload event of this hidden form
instead of insisting on the user using your close button.

--
Wayne Morgan
Microsoft Access MVP


When an Access databae is opened, there's a X button at the top right of
the window. ( just like every other application or window). Is there anyway
to run a macro/sub/function when this X button is clicked?
If not, is there any way to hide this button?

In Excell we can create a sub in workbook objects's on-close event. Is
there any way to do the same task in Access?

Any kind of help is much appreciated.

I need to oblige the users to click a button in a form to close the
database.

Ghalamkari
 

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