Link to home
Start Free TrialLog in
Avatar of jackbenson
jackbensonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Application.Quit not working in Access 2010

Hi,

i have written my company's stock system in an Access 2007 front end connecting to a MS SQL server for the Database.

I want to roll out Access 2010 and am testing it on the development machine.

There seem to be a couple of issues, but i have one that i can't get past.

In the database there is a main form. When that form is closed - it triggers the Form_Unload event.. and in that event the code Application.Quit is called and the application quits.

In Access 2007 and 2010 - if you close the main form the application exits properly.

BUT....

in Access 2007 - if you click the click on the X button in the top right hand corner of the access application (not the main form), it causes the main form to close and the application.quit runs and the application exits properly.

in Access 2010 - if you click the click on the X button in the top right hand corner of the access application, it causes the main form to close but it ignores the application.quit code and continues past it and code runs that should not run.

can anyone explain why the Application.Quit is iqnored in Access 2010 when you close the database from the top right and X button?

thanks

jack
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jackbenson

ASKER

i dont know how it can be happening... but when you close the access database from the X in the top right hand corner (is there a technical name for this button?) the following events are called in the following order on the form that controls the database:

Form_Unload()
Form_Load()

i cant understand why the Form_Load() would be called at all. there are no references to it. i have prooved it by putting msgbox commands in the Form_Load()

there is a load of code that runs in the Form_Load that should not run again after it has been run once.

can anyone replicate this?

thanks

jack
Any code that could Load the form in ANY event?

Any Subforms on that form?

If you have a situation where Events are being called out of order, you might have a corrupt database. Have you tried Compacting the database?

If that doesn't help, a Decompile might be in order. Build a Shortcut and set the Target to this:

"full path to msaccess.exe" "full path to the database" /decompile

Run this, then Compact again.

If those don't help, then try building a new, blank database and importing everything into that new database.
the decompile / compact did not help.

i will build a new database and import everything and will let you know how it goes

thanks

jack
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks, thats what i have done..  i have got round it by putting a if statement that checks if the startup operations have already run. if they have it exits the Form_Load()

i will have a good look though my code at some point to work out what is causing this problem

thanks for all your help.

jack
thanks for all your help!