Access 97/2003 - Not Closing Access Properly

  • Thread starter Thread starter Craig Alexander Morrison
  • Start date Start date
C

Craig Alexander Morrison

Hello all

I have an application, now over 10 years old (although extensively upgraded
several times) starting in Access 2 now in 97 and 2003.

Both the recent versions of the 97 and 2003 versions (sometimes) remain on
the taskbar once the application has been closed. When you try to close it
by right-clicking and selecting close it does nothing. Usually you need to
hit CTRL+ALT+DELETE and use the task manager to close it down to get rid of
it.

When testing in design mode and running the application the Microsoft Access
box sometimes stays on the taskbar after it has been closed. When in runtime
mode the application sometimes leaves a blank box on the taskbar. I have
been unable to trace anything being left open (an instance not properly
destroyed etc) this I suspect is the most likely problem.

The application is very complex so I am only looking for ideas from anyone
that has had a similar experience so that I can try to focus my efforts to
resolve this.

It seems to happen more often, though not exclusively, when the user clicks
the Access Main Window Close Icon. There are a couple of forms which have
Application.Quit in their close events, although there are two other
applications in this system with the same arrangement and they do not
generate this problem. Both of these forms are always open although only the
Main Menu form is visible, the Logon form stays hidden once the user logs
on.

Any experiences would be appreciated.
 
Craig, there were 2 problems that caused this problem in Access 97, but
neither of them apply to A2003 AFAIK.

The 2 A97 issues were:
- failing to close set Recordset objects *and* set them to Nothing in the
Exit section of every procedure that opened them (including error recovery);
- referring to a binary control (check box, toggle button option button)
like this:
If Me.Checkbox1
Solved with any of these:
If Me.CheckBox1 = True Then
If (Me.CheckBox1) Then
If Me.Checkbbox1.Value Then

IME, A2003 failing to close could be because of an event queue, alteration
to an object in use, or an incipient corruption. Since these issues can
affect A97 as well, these might be your starting point.

Actually, there was a problem in one of the JET 4 versions with
Application.Quit, and IIRC the issue did not apply to DoCmd.Quit. That's a
pretty simple search'n'replace, so probably worth a try.

To avoid the corruption issue, check the list here:
http://allenbrowne.com/ser-25.html
Lots of things such as inconsistent JET 4 service packs among the machines
using the database, Name AutoCorrect, failing to split, actually opening an
A97 database directly in A2003 instead of creating a separate 2003 front end
into the A97 back end, and so on. Even a simple Decompile could solve the
problem if it is an incipient corruption.

A minor one, but we have also found that explicitly saving a dirty form
avoids all manner of minor issues, because it clears the event queue (both
the control's events and the form's events) before Access tries to do the
next thing (such as closing the form, applying/removing a filter/sort,
reassigning recordsource, opening something else that uses the same data,
....)

Others may have further suggestions, but HTH.
 
Well done, Allen, I really appreciate this, funny how it seemed to work for
8 years until we added some extra processing in the last year or so.

"- referring to a binary control (check box, toggle button option button)
like this:
If Me.Checkbox1
Solved with any of these:
If Me.CheckBox1 = True ..."

It was the above that fixed it, at first I changed what I though was all
such checks and no joy; however then I found the forms that were causing the
problem have at least a dozen of these types of check, once all were changed
it worked. I have never come across this before, is it an intemittent fault,
or can you get away with it in some circumstances? Some of the code I
changed is over 8 years old.

Is the fault present when you ask the question If Not Me.CheckBox1 also?

The Access 2003 version did not actually misbehave when I investigated it
further.

Thanks for your help. BTW Do you know the old knowledge base number for
this? - only if you happen to know.
 
Wow. Haven't seen that crop up here for a couple of years.

I don't know the kb article without searching. The issue seemed to be that
Access created a reference to the object and failed to release it. Microsoft
recommended:
If Me.CheckBox1 = True
because that was enough to get it to resovle the reference correctly.

I personally perfer:
If Me.CheckBox1.Value Then
because that is exactly what you mean (referring to the default property of
the object), and avoids the unnecessary construct that equates to:
If True = True Then

Michka reported that:
If (Me.CheckBox1) Then
was enough to get Access to evaluate the expression as a value instead of an
object.

In a large project, this kind of thing was not easy to track down, so well
done.
 
I never had problems with Recordsets because I always considered it a sign
of failure (Access, SQL or me) if I had to use one. (vbg)

When I use Recordsets I always do my best to close them and all other
database objects as soon as I can.
 
I had a look at an old version of the knowledge base DVD (June 2001) and
"Q190074 - Unable to quit Microsoft Access" details the error. The current
DVD (June 2005) has dropped Access 97 although it is still
available online as article 190074.

Microsoft state that it is actually when you use the - Me.Parent!CheckBox
Then - construct that the error can occur, you can get away with -
Me!CheckBox Then -, probably.

I also think it can happen when you reference a boolean control on another
form, such as a custom dialog box for a report. Anyway as most of my current
developments are in 2003 I will stick with my old ways and remember this
when I revisit the systems we have that are still based on Access 97. Until
we go 64bit it is difficult to justify the move from Access 97 to the latest
version even if it takes me only a few minutes to convert the applications
(without issues), which it does.

Anyway thanks Allen and Albert.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top