Solved

DoCmd.Quit closes database, but leaves Access up

Posted on 2014-01-07
10
734 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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 - 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 35

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

777 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