Solved

DoCmd.Quit closes database, but leaves Access up

Posted on 2014-01-07
10
818 Views
Last Modified: 2014-01-09
Hello - I have one user that has recently started seeing this strange behavior in a particular app. I put a button on the main menu that issues the DoCmd.Quit command. Works fine for me, but with her, just recently, it closes the database, but leaves Access up.

Any ideas? We are both running W7 and Office/Access 2010  

Thanks
0
Comment
Question by:mlagrange
[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
10 Comments
 
LVL 58
ID: 39763467
This is due to poor garbage cleanup in Access and VBA.  When an object goes out of scope, the object is supposed to be removed from memory and any pointers cleared.  That doesn't always happen.

Access tracks open objects for use with automation and when the count reaches zero, it knows it can close.

Bugs in Access can also lead to this.

What you need to do is in code:

1. Make sure you close anything you open
2. Make sure you set object variables = nothing

ie.

  Dim rst as DAO.Recordset

  Set rst = CurrentDB().OpenRecordSet("mytable")

 .... do stuff..

  rst.close
  Set rst = nothing.

Jim.
0
 

Author Comment

by:mlagrange
ID: 39763567
Yep, I do that. But still, it's closes all the way out for me, and it used to for her, just not now.

Something has changed somehow; maybe it's one of those things that goes away with a re-install of Office/Access?
0
 
LVL 58
ID: 39763633
Does it just minimize to the task bar or does the main Access window remain up?

Jim.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 38

Expert Comment

by:Jim P.
ID: 39763885
What happens if you change it to DoCmd.Quit acQuitSaveAll?
0
 

Author Comment

by:mlagrange
ID: 39763963
The main Access window remains up

I'll try that tomorrow. I'm also going to try Application.Quit, and see if that works for her.

Thanks, Jim. I'll be back tomorrow
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 39764013
This problem seems to be a lot more prevalent in A2010 that A2003. I have this issue in 3 dbs at work.  This is the 'solution' that worked for me ( if you can call it a solution):

Have your users close all open Forms/Reports before ... using the X button to close Access or a File>Exit.  Or in you case I guess since you have a main menu with a close button - have the Close button Close any open Forms/Reports before executing the Quit operation.


btw ... This article  shows you how to close all open forms. Would be similar for Reports.
mx
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39764344
You need to compare settings on both machines.

Try:
DoCmd.RunCommand acCmdExit
0
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 39764816
<<The main Access window remains up>>

 It's not the reference count then.   Access minimizes to the task bar when it thinks it has open references and you tell it to close.

 Just to double check, you've already updated this users copy of the app correct?   have you tried their copy of the application somewhere else?


or are you all sharing a single copy from somewhere on the network?

Jim.
0
 
LVL 38

Expert Comment

by:PatHartman
ID: 39765374
I use
Application.Quit acQuitSaveAll

Technically the acQuitSaveAll isn't necessary since the user would never be changing objects.  I use it so that when I am testing, anything I might have open that I forgot to close will be saved.
0
 

Author Comment

by:mlagrange
ID: 39768354
Hello - thank you all for all of your suggestions. This user got the same results from both DoCmd.Quit and Application.Quit

What seemed to have fixed it was just doing a Decompile on the front end.

Jim - we are both using the same front end from the network. There may be an additional complication in that she sometimes opens the app from home, over a very slow Citrix connection, and I think that might crap up the accdb to some extent during the close(particularly in Access 2010)  

Joe - I've got a fairly tight menu routine that hides the main menu when the user selects (opens) a given form, then shows the main menu when that form is closed, so I can be fairly sure that if they are closing the app form the "Exit" button on the main menu, there are no open forms.

Again - thanks everybody for your responses.

Mark
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

636 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