Solved

DoCmd.Quit closes database, but leaves Access up

Posted on 2014-01-07
10
718 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

911 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

20 Experts available now in Live!

Get 1:1 Help Now