confirm before exit

lala

Registered User.
Local time
Yesterday, 19:21
Joined
Mar 20, 2002
Messages
741
hi
i have a question
is there any way to have a confirmation box pop up on exiting access?
or can i hide the X button for access itself, not just the forms?

here's why
my boss always clicks the X by accident, when he only means to minimize it or open another application
i showed him the SHOW DESKTOP button 100 times, explained to him that you don't have to minimize stuff to open other things, but nothing works
everytime he wants to open another application, he starts killing existing ones


so either hiding the button or having a confirmation box would solve that problem
but how do i do that

and is there any other suggestions?

thank you
 
I have this that I call in the Unload event of my form:

Code:
    Dim varResp As Variant
    ' this sub closes the program while leaving Access open
    On Error GoTo err_handler
    varResp = MsgBox("If you want to EXIT Access completely, press YES. " & vbCrLf & _
                     "If you want to CLOSE the program while leaving Access open, press NO." & vbCrLf & _
                     "If you want to CANCEL and go back to the program, press CANCEL.", vbYesNoCancel, "Close Confirmation")
    Select Case varResp
    Case vbYes
        DoCmd.Quit
    Case vbNo
        CloseCurrentDatabase
    Case vbCancel
        Cancel = True
        Exit Sub
    End Select
    Exit Sub

err_handler:
    If Err.Number = 2763 Then
        Exit Sub
    Else
        If MsgBox(Err.Description & vbCrLf & "Do you wish to continue?", vbCritical + vbYesNo + vbDefaultButton1, "Error number: " & Err.Number) = vbYes Then
            Resume Next
        Else
            Exit Sub

        End If
    End If
 
thank u very much!!!!!!!!!!!!!
 
the only problem i have with that is that their database is still being worked on (by me) and always will be. they always come up with more ideas and i implement them.

and with this, i can't go in the design of the form
the only way i can get to the design is if i go into the design of some other form, open the code of the main form and disable the unload procedure

is that how it's done, or i just don't know something?
 
True, what I've done is to put a hidden box on the form so I can double click it and it sets a boolean flag, create a boolean variable in a standard, not form, module as public (Public blnEdit As Boolean) and then set it in the double click event (blnEdit = True) and then have the test in the code to exit so that if the blnEdit=True then it doesn't run it.
 
i know i can also keep a copy of the database without the event

when i need changes done, i work on it and when i'm done, save it, make a copy and put the event there.
that way there's always a copy without the unload event.

any other suggestions?
 
ooohhhhhhhh
i would've thought of that, but much latr

thanks a lot
 
but the way i would do it is

make a button that on click would clear the UNLOAD event

me.unload=""

and another one that on click will put it back
me.unload="[event procedure]"

no?
 
in case u're wondering why i'm doing things the way i do them

i don't know too much of the code
i created pretty complicated databases, and to work around using a lot of code, i came up with many nocode solutions
like i wouldn't know how to do what you told me to do
i understood the concept, but don't even know what half of the words mean

ok, i gotta go to sleep
thanks a lot for your help, i will check your post tomorrow
 
No, not a good way. In fact, I don't think it would work.

In a standard module (not a form module) up in the General Declarations Section have:
Code:
Option Database Compare
Public blnEdit As Boolean

Then, put a small box drawing object on the form, with the background set to Normal (not Transparent or it won't work) and the same color as the form. In it's double-click event put
Code:
blnEdit = True

Then in your other code change it to:

Code:
    Dim varResp As Variant
    ' this sub closes the program while leaving Access open
    On Error GoTo err_handler

[color=red]If blnEdit = False Then[/color]
    varResp = MsgBox("If you want to EXIT Access completely, press YES. " & vbCrLf & _
                     "If you want to CLOSE the program while leaving Access open, press NO." & vbCrLf & _
                     "If you want to CANCEL and go back to the program, press CANCEL.", vbYesNoCancel, "Close Confirmation")
    Select Case varResp
    Case vbYes
        DoCmd.Quit
    Case vbNo
        CloseCurrentDatabase
    Case vbCancel
        Cancel = True
        Exit Sub
    End Select
[color=red]End If[/color]
    Exit Sub

err_handler:
    If Err.Number = 2763 Then
        Exit Sub
    Else
        If MsgBox(Err.Description & vbCrLf & "Do you wish to continue?", vbCritical + vbYesNo + vbDefaultButton1, "Error number: " & Err.Number) = vbYes Then
            Resume Next
        Else
            Exit Sub

        End If
    End If
 

Users who are viewing this thread

Back
Top Bottom