Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2008

Tip: Looking for answers? Try searching our database.

Running code at app closing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 12 May 2008 05:48 GMT
Hi

How can I detect when user is closing the app by closing Access (2000) so I
can run some end of day routines?

Thanks

Regards
Tom Wickerath - 12 May 2008 08:21 GMT
Hi John,

One way is to have a form that you open in hidden mode, via an Autoexec
macro. Add code to the close event of this form. The hidden form can serve
double duty--it can be used to maintain a persistent connection to the BE
(back-end) database in a split multiuser Access application. More details
here:

    Implementing a Successful Multiuser Access/JET Application
    http://www.accessmvp.com/TWickerath/articles/multiuser.htm


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

> Hi
>
[quoted text clipped - 4 lines]
>
> Regards
John - 13 May 2008 03:09 GMT
I have tried opening my required form in the Close event of the hidden form
but the result is that the required form appears only for a second and then
disappears.

Regards

> Hi John,
>
[quoted text clipped - 22 lines]
>>
>> Regards
John - 13 May 2008 03:17 GMT
OK, I am now opening my required form as Dialog and it does stay but I don't
have access to it, in that clicking on this form has no effect. Eventually I
have to crash access to get out.

> Hi John,
>
[quoted text clipped - 22 lines]
>>
>> Regards
John - 13 May 2008 03:36 GMT
If I run the below code in Unload event of hidden form then the required
form MyForm does get control and closing this form allows Access to close
but in a few moments Access crashes with prompt to send error report.

Private Sub Form_Unload(Cancel As Integer)
 If MsgBox("Do you want to do this before exiting app?", vbQuestion +
vbOKCancel, "App Quiting Process") = vbOK Then
   DoCmd.OpenForm "MyForm", acNormal, , , , acDialog
 End If
End Sub

> Hi John,
>
[quoted text clipped - 22 lines]
>>
>> Regards
Tom Wickerath - 13 May 2008 06:57 GMT
Hi John,

I haven't tested this; it may or may not work...
Try canceling the unload event of the form if the user clicks on OK:

Private Sub Form_Unload(Cancel As Integer)
 If MsgBox("Do you want to do this before exiting app?", _
         vbQuestion + vbOKCancel, "App Quiting Process") = vbOK Then
   Cancel = True
   DoCmd.OpenForm "MyForm", acNormal, , , , acDialog
 End If
End Sub

Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

> If I run the below code in Unload event of hidden form then the required
> form MyForm does get control and closing this form allows Access to close
[quoted text clipped - 6 lines]
>   End If
> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.