How to prevent Access from Closing

G

Guest

I want to make sure that Users always exit my database using Exit Button
provided on my SwitchBoard Form. How ever I am unable to prevent them from
Closing Access Itself, As the user click on X Button of Windows and it closes
Access. Is there a way to control how to exit Access.
Please note that my SwitchBoard Form remains open till user Exit the database.

There was a tips on Webpage: www.mvps.org/Access , But the method is not
working.

Could any of the professionals can advise me what to do in details, as I am
not very good in Access VB coding.
 
S

Steve Schapel

Irshad,

I think this may be similar to what you saw on The Access Web:

1. Open your Switchboard form in design view, and open the VB Editor
window (via the View|Code menu).
2. At the top of the module, put the following right after where it says:
Option Compare Database
Option Explicit
Dim AllowClose As Boolean
3. In the On Load event property of the form, put this code...
AllowClose = False
4. On the On Click event property of the button you use to close the
database, put this...
AllowClose = True
<then your other code to close the database etc>
5. On the On Unload event property of the form, put this...
If Not AllowClose Then
MsgBox "Please use the button!"
Cancel = True
End If
 
G

Guest

Thanks Mr. Steve,
It worked Fine. My mistake I discovered of mine was the one you have
mentioned in the 5th Point.
Hope the other readers will benifit by this. As this is small but is a
interesting one. As Generally user use to quit Access from any Form without
coming to Switch Board or closing other forms.
Regards.
Irshad.
 

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