Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Application.Quit not working in Access 2010

Posted on 2010-11-12
8
Medium Priority
?
3,166 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:jackbenson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 168 total points
ID: 34119181
I agree with your description of the situation.

But I'm not quite clear what sort of code you would put after an unconditional  .quit command.
Under what circumstances woud you be expecting it to run?

This might be a bug or it might be MS being 'clever' ("If i'm in the middle of a .quit then ignore any further .quit commands") and not seeing the whole picture.

In my view this is an unusual approach - I would have said that the more common situation would be that developers would be using the form_unload event procedure to PREVENT someone closing the app using the Access X and forcing them into an orderly shutdown, if that's what they intended.  So it might be something that escaped MS.
0
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 164 total points
ID: 34119214
I'd use the Form's Close event for this, since it cannot be canceled. The order of events for this is

Unload - Deactivate - Close

Since Close is the LAST event, and you're trying to exit the app, then move your code there.
0
 
LVL 1

Author Comment

by:jackbenson
ID: 34127664
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
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 85
ID: 34127956
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.
0
 
LVL 1

Author Comment

by:jackbenson
ID: 34128224
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
0
 
LVL 10

Assisted Solution

by:t_hungate
t_hungate earned 168 total points
ID: 34131950
Perhaps adding to you On Load code to check and see if the form has already been loaded.  If so, then exit your routine.  That should prevent the code from running during the Unload, or Close of the form.
0
 
LVL 1

Author Comment

by:jackbenson
ID: 34132046
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
0
 
LVL 1

Author Closing Comment

by:jackbenson
ID: 34132051
thanks for all your help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question