Darren Dick
D.Dick at uws.edu.au
Wed Jul 27 20:55:41 CDT 2005
That code will do it Put the code in the Unload of the form as the Unload Event has a cancel option So....copy and paste this code below into any form Then try and close the app. Private Sub Form_Unload(Cancel As Integer) If MsgBox("Are you sure you want to close Jeremy's way cool application completely?", vbQuestion + vbYesNo, "Confirm Application Close") = vbYes Then 'User chose yes so let 'em quit 'Put some code to here that allows them to exit gracefully 'IE close other forms, close reports, stop any processes etc DoCmd.Quit Else 'User Chose no - so do nothing Cancel = True ' this will stop the action that faised the Unload to occur IE closing the APP :-)) End If End Sub DD -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jeremy Toves Sent: Thursday, July 28, 2005 11:06 AM To: Access Developers discussion and problem solving Subject: RE: [AccessD] Fwd: Quitting Application Problem That seems to be part of it, but something has to happen to keep the database open once it hits the Else. If I leave it as is, then the database closes when the form unloads. Is there something I can code to keep the form loaded, even if somebody tries to close the application by hitting "x"? Is there a way to hide the"x"? Thanks, Jeremy Darren Dick <D.Dick at uws.edu.au> wrote: Hi Jeremy There are a number of ways. Here's one Have a frm call it say...frmHidden Have it open each time your app is started. Put it in an AutoExec Macro. (Lemme know if you are unsure what an AutoExec Macro is) But have the macro open the form 'hidden' - IE not visible to anyone at all. In the On Unload or OnClose of that hidden form have something like... If msgbox ("Are you sure you want to close Jeremy's way cool application completely?",vbquestion + vbyesNo, "Confirm Application Close")=vbyes then 'User chose yes so let 'em quit 'Put some code to here that allows them to exit gracefully 'IE close other forms, close reports, stop any processes etc docmd.quit Else 'User Chose no - so do nothing End if The way it works is...if the whole app is going to be closed then this hidden form will be claosed also Sparking the OnClose or OnUnload code thus allowing them to think about closing completely or not Via the message box that pops up Hope this helps Darren -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jeremy Toves Sent: Thursday, July 28, 2005 10:03 AM To: AccessD Subject: [AccessD] Fwd: Quitting Application Problem Let me try this again. I just realized my original message never made it to the group. Help? Thanks, Jeremy Jeremy Toves wrote: Date: Wed, 27 Jul 2005 13:03:00 -0700 (PDT) From: Jeremy Toves Subject: Quitting Application Problem To: AccessD I have a database that needs to complete a few processes before it is closed. Some of the users are closing the application by using the "x" in the upper right corner of the Access database. Is there a way to disable this? Or can a message prompt the user to complete processing before exiting? Any help would be appreciated. Thanks, Jeremy Toves -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com