Cancel Closing the Form/App

BCullenward

Registered User.
Local time
Today, 16:38
Joined
Jul 6, 2005
Messages
28
I'm looking for a way to cancel the closing of a form/app. I added a button asking if the user is sure they wish to exit, and am having difficulty finding the correct code to cancel the close event.

Here is my code
Code:
Dim ians As Integer
        ians = MsgBox("Are you sure you wish to exit?", vbYesNo, "Exit App")
        If ians = vbNo Then
            DoCmd.CancelEvent
            DoCmd.OpenForm "orderlist", acNormal
            Exit Sub
        End If

Can help or send me down the right path?

Thanks
 
Last edited:
Nevermind.
I had that close in the Close Event. I moved this to the Unload event and it works now.

Code:
        Dim ians As Integer
        ians = MsgBox("Are you sure you wish to exit?", vbYesNo, "Exit App")
        If ians = vbNo Then
            cancel = 1
            DoCmd.CancelEvent
            Exit Sub
        End If
 

Users who are viewing this thread

Back
Top Bottom