Sometimes users (including myself) accidentally click on the application
close icon in the application menu bar when they meant to just click on the
'X' for the form. Of course the app closes and this is very annoying.
So, I added a messagebox to my hidden StartAppForm in the Unload event. Now
when the application closes the user is presented with a message so they can
abort closing in case they don't really want to close. This has been working
very well.
However, I forgot that there are cases where I want to force a shutdown
regardless of what the user wants (i.e. user doesn't agree to license, etc).
I'm using either DoCmd.Quit or Application.Qui t in these instances. When this
happens, the afore-mentioned messagebox appears "Do you really want to close
the application" with a Yes/No button. Regardless of what the user selects,
the app closes. While this is not a showstopper and an events occur as I want
them to, the appearance of this messagebox in this case looks unprofessional.
So I thought I would just add a global boolean variable: BypassCloseMess age.
This variable would be set to True just before any DoCmd.Quit or Application.
Quit code statement. Then in the hidden StartAppForm Unload event, the code
would check the value of this global boolean variable. If True, bypass the
messagebox and continue closing.
I thought that this would work. However, it doesn't. I've checked the code
and it looks correct.
When using the DoCmd.Quit or Application.Qui t command, does this cause the
global variables to go out of scope immediately. I tried putting a break in
the StartAppForm Unload event, but the code won't stop there after the DoCmd.
Quit or Application.Qui t command has been invoked. The application closes and
disappears from the screen. BUT, the messagebox "Do you really want to close
the application" does appear as the last thing on the screen (even though the
rest of the app is no longer viewable). Regardless of what the user selects
it is then closed.
So how can I solve my problem and it would be great if someone could explain
why this behaviour is occurring.
Thanks
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200612/1