Hi!
Nothing out of the norm. I havent even got to the part where I stop the unload - Im still not seeing the QueryUnload fire at all! I do get msgboxes when I use the unload - and stopping it there is tough.
Private Sub Form_QueryUnload(Cancel As Integer, unloadmode As Integer)
Select Case unloadmode
Case vbFormControlMenu
MsgBox ("close button pushed:" & unloadmode)
'Cancel = 0
Case Else
MsgBox ("Properlogout:" & unloadmode)
'Cancel = 1
End Select
This form is the logout form, replacing a vbYesNo popup. If they hit logout, it gracefully closes down, or else re- opens the main menu. I am capturing the "X" close, so it says "use the logout button". So basically what's happening now is that no matter if i click logout or X, it always says the X button pushed. Putting the cancel to true, stops the unload though.
Private Sub Form_Unload(Cancel As Integer)
Select Case unloadmode
Case vbFormControlMenu
MsgBox ("X button pushed:" & unloadmode)
Cancel = True
Case Else
MsgBox ("Proper logout button:" & unloadmode)
Cancel = False
End Select
you need VbYesNo..how else are you telling the DB what the user pressed? then you must tell the DB what the user pressed..thats why I posted the code with Resp = Whatever.
I was trying to get away from pop ups... I have decided to scrap a whole bunch of code and move in another direction. Hopefully I will use your code in another endeavour. Thanks for your advice!
Don't give up so easily! Try adapting your method using a variable.
In the Declarations section of your Form:
Dim booCanClose As Boolean
In the On Load or On Open event:
booCanClose = False
In the On Click event of your Close button:
booCanClose = True
DoCmd.Close acForm, Me.Name
In the Form's UnLoad event:
If booCanClose = False Then
MsgBox "Improper logout method:"
Cancel = True
Else
MsgBox "Proper logout method:"
Cancel = False
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.