Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ACCESS fails to close

Status
Not open for further replies.

cyberbiker

Programmer
Mar 16, 2001
431
US
I know I saw something on this a while back, but cannot seem to locate the thread.
I have an app written in ACCESS97 that will not totally close under many conditions. The database closes, but an instance of ACCESS stays open. The user must use ctrl-alt-delete then end task then do it a second time and select end or else reboot.

From recent experiences and analyzing how this happens I believe ACCESS is not releasing some resources somewhere.
Many of my forms use bound controls although some do not.
I suspect that I need to close either workspaces or recordsets. I am not quite certain how to do that when I do not explicitly open a recordset in code.

Since some users are becoming irritated and since they are irratating my boss, I really need to solve this. Any ideas Terry (cyberbiker)
 
The problem is as you say usually due to not releasing resources.
What you need to do is whereever you have
Dim X as Object (or Recordset, or Database, etc) make sure that you put set x=nothing at the end of the code.

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Sorry, I may not have been clear.
The problem is that I have a lot of things like this:

frm1.recordsource = query1

I use similar code as this to close each query when I unload the form

DoCmd.Close acQuery, query1

I also have set the recordsource property at design time in many cases and those resources may not be being released

controls on the form are bound.

This app was my first real experience with database programming and I now realize that that I really should have done things differently, but changing it is not a good option right now.

The question is how do I set query1 to nothing or set the recordsource to nothing? Terry (cyberbiker)
 
Ah! I see the problem. We are getting recordsource mixed up with recordsets.
A recordset is an object containing data you can manipulate using code. It is completely different to record source which is the data a form or report looks at.
What I suggest you do is systematically go through your database and try one thing at a time to see what actions are causing your db to behave this way. Then have a look at the code you ran last and try to see where your problem is. If you are still stuck, then post the code here & I will look at it.

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Thanks Ben, But I am not being clear again.

What I have done with this program is to set the record source property to a query name depending on how the form is opened from a "Search form" This is done in code at the form load event. Once set, I do not change it.
Some forms can have the record source property set to one of 5 queries. Some forms have had the record source property set to a query at design time.


The controls are then bound to that recordsource.
Since I do not explictily create a recordset in code, I have not figured out how to set the recordset back to nothing.

When I close each form I use the form close event:

Private Sub Form_Close()

DoCmd.Close acQuery, strJobQueryName

End Sub
strJobQueryName is a variable assigned the value of the queryname needed.

I have created an MDE file for the front end which is installed on the client and have the backend on the server still as an mdb.

The problem appears to occurr randomly (with the understanding that randomly means I have not yet found a pattern).

Also, I did not have this problem while testing on my pc initially. It does happen on my pc now regardless of wheter I am testing the MDB or have created the mde and test that.

I also used switchboard manager to create a menu and modified the code generated to fit my needs.

Please be aware, that I have been working on another project converting a VB app using ACCESS97 tables and jet to
using SQL Server and ADO and have learned quite a bit about where I went way wrong on the first app (which is the one I need to fix). Using bound controls and queries seems to be a good way to get into trouble real fast. And I will never do that again.
I just need to find a quick way out of this without spending major time rewriting this first app if possible. Terry (cyberbiker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top