Group:  Microsoft Access ยป microsoft.public.access.forms
Thread: 'database close' event

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

'database close' event
"Jesse Aufiero" <jaufiero[ at ]moaboil.com> 15.09.2006 18:14:19
How can i execute code when the access database application closes. is
there a way to hook into a 'database_close' event, or the like? thanks!


Re: 'database close' event
Steve Schapel <schapel[ at ]mvps.org.ns> 15.09.2006 19:04:06
Jesse,

As far as I know, this is not directly possible.

One way to handle this kind of requirement is to enforce that the only
way the application can be closed is via a command button on a form
which is always open when the application is open. The means of doing
this is like this...

In the Declarations section at the top of the code module for the form,
put like this...
Dim AllowClose As Boolean

On the Load event of the form, put...
AllowClose = False

On your 'Exit' button, put...
AllowClose = True
DoCmd.Close acForm, Me.Name
DoCmd.Quit

On the Unload event of the form, put...
If AllowClose Then
' < your code that you want to run when the app closes >
Else
MsgBox "Use Exit button to close", vbExclamation, "Illegal escape"
Cancel = True
End If

--
Steve Schapel, Microsoft Access MVP

Jesse Aufiero wrote:
[Quoted Text]
> How can i execute code when the access database application closes. is
> there a way to hook into a 'database_close' event, or the like? thanks!
>
>
Re: 'database close' event
"Jeff Boyce" <nonsense[ at ]nonsense.com> 15.09.2006 19:07:39
Jesse

One way you could do this would be to open a form when the application
opens, but open it "hidden".

In THAT form's OnClose event, put what you want to have happen.

When the database closes down, that form closes and your code is triggered.

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Jesse Aufiero" <jaufiero[ at ]moaboil.com> wrote in message
news:uF35iOP2GHA.1252[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
> How can i execute code when the access database application closes. is
> there a way to hook into a 'database_close' event, or the like? thanks!
>


RE: 'database close' event
Klatuu 15.09.2006 19:10:02
If you have a form that stays open as long as your application is open, you
can put the cde in the Close event of that form. The form can be visible or
hidden.

"Jesse Aufiero" wrote:

[Quoted Text]
> How can i execute code when the access database application closes. is
> there a way to hook into a 'database_close' event, or the like? thanks!
>
>
>
Re: 'database close' event
Steve Schapel <schapel[ at ]mvps.org.ns> 15.09.2006 19:22:54
.... or, if you prefer to do it the easy way, follow Jeff's and Klatuu's
advice ;-)

--
Steve Schapel, Microsoft Access MVP

Steve Schapel wrote:
[Quoted Text]
> Jesse,
>
> As far as I know, this is not directly possible.
>
> One way to handle this kind of requirement is to enforce that the only
> way the application can be closed is via a command button on a form
> which is always open when the application is open. The means of doing
> this is like this...
>
> In the Declarations section at the top of the code module for the form,
> put like this...
> Dim AllowClose As Boolean
>
> On the Load event of the form, put...
> AllowClose = False
>
> On your 'Exit' button, put...
> AllowClose = True
> DoCmd.Close acForm, Me.Name
> DoCmd.Quit
>
> On the Unload event of the form, put...
> If AllowClose Then
> ' < your code that you want to run when the app closes >
> Else
> MsgBox "Use Exit button to close", vbExclamation, "Illegal escape"
> Cancel = True
> End If
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net