tags:

views:

288

answers:

4

I am debugging a Microsoft Access program that occasionally hangs when users click on the quit button after been using the program for a long time. This program is just a lean Access front end with a SQL database back end.

One thing that puzzles me is that the quit button does nothing except for the following command:

DoCmd.Quit

Right now I'm suspecting this could be caused by the antivirus. MS Access will try to write (compacting) the database file on exit and the antivirus probably doesn't like that.

However, I'm just wondering anyone else had this problem before? Anything else that could cause this issue?

+2  A: 

The DB probably has automatic compaction..and docmd.quit exercises that option. A compaction of a largish db, even if it is sql backed, can take enough time to look like a hang.

Try this...

Application.Quit acQuitSaveNone will close faster but will not compact.

CMB
I'll give it a try thanks +1
oykuo
+2  A: 

I have experienced this kind of behaviour and it was casused by code that used a static DAO Recordset that failed to close it.

Static rs As DAO.Recordset
'Missing code
rs.Close

Bit obscure but you never know...

This was when closing the application by any means though.

Mark3308
Oo I but that took a moment to find...
mavnn
yes - I was pulling my hair out for about 3 weeks (back when I had hair)
Mark3308
A: 

If you have COMPACT ON CLOSE turned on,

TURN IT OFF.

It is a worthless "feature" that never should have been added to Access in the form that it was implemented.

  1. there is no Access application but the most trivial that should not be split into front end (forms/reports/queries/modules) and back end (tables only). A properly-designed front end will never bloat beyond a certain percentage and does not need to be compacted. It's only the data tables that need compacting. COMPACT ON CLOSE will thus not be compacting the data at all, just the front end, so it's worthless.

  2. if you have it turned on in your back end, you can lose data, with no recourse. This is because some forms of corruption in Jet/ACE allow you to use the data without problems, but as soon as you compact, data is lost. Thus, before compact, a table might have 100 records, and after a compact, 98, because the corrupted records were lost in the compact operation. Since this generally happens without it being noticed, COMPACT ON CLOSE puts you in the very dangerous position of compacting without being able to cancel it so that if your file is corrupt, you can lose data.

Don't use COMPACT ON CLOSE. It is both valueless and dangerous.

David-W-Fenton
A: 

Try closing all your forms and running docmd.quit from the command window to see if you get the same behavior.

If not, it might be some teardown code in one of your forms that executes when the form is closed. I have seen it before where this type of code gets in an infinite loop or there is a teardown problem in objects that have cyclical dependencies.

If this turns out to be the issue, repeat the above step with each form that is typically open when you press your "Quit" button until it happens again and then inspect the code that runs when that form is destroyed.

JohnFx