Solved

DoCmd.Quit closes database, but leaves Access up

Posted on 2014-01-07
10
689 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
10 Comments
 
LVL 57
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 57
ID: 39763633
Does it just minimize to the task bar or does the main Access window remain up?

Jim.
0
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) 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 57

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 34

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now