Re: How to prevent Access from Closing

From: Irshad Alam (IrshadAlam_at_discussions.microsoft.com)
Date: 12/13/04


Date: Mon, 13 Dec 2004 02:35:02 -0800

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.

"Steve Schapel" wrote:

> 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
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Irshad Alam wrote:
> > 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.
> >
> >
>