unload in runtime

  • Thread starter Thread starter LGarcia
  • Start date Start date
L

LGarcia

Hi all,
I have a hidden form that runs some code when access shuts down. I added
this code to the hidden forms unload event:
If MsgBox("Do you want to exit?", vbYesNo, "Exit") = vbNo Then
Cancel = True
End If
Works fine from my switchboard button (runs a macro with only the Quit
command) and if use the X in the top right corner. Problem is when I run it
in runtime.If I use the X in the top right corner to shut down it works
fine. But if I use the button on the switchboard (runs the Quit macro) I get
an error: "Execution of this application has caused a runtime error"
Anyone know why this is happening?
Thanks!
LGarcia
 
Hard to tell. Add some more precise error handling to the code, and try to
catch what the problem is. Add msgboxes along the way to report statuses.
 
Thanks for the reply!
I tried your suggestion and I was able to find the cause of the error. It
came from some code I have on the close event of my hidden form. The thing
that most bothers me is that in runtime the "cancel = true" statement is
ignored and is still trying to close the form.
I also changed the code from the Exit button on my switchboard from
CloseCurrentDatabase to DoCmd.Quit. Now I don't get an error but access
still closes when I chose No from my msgbox. Oh well.....
 
Back
Top