Problem creating code reference to another Access database

  • Thread starter Thread starter JF
  • Start date Start date
J

JF

I have an Access application in which I have a reference to another Access
..mdb file so I can use some of the latter mdb's functions.

The problem is, after leaving the main application, the referenced mdb
remains "open". That is, the ldb file still exists and if I go into the
Task Manager, the instance of MSACCESS.EXE is still alive.

Now, I've narrowed this problem down the specific instance where I load the
form that contains calls to the referenced mdb. So, I can open my main
application, move around in it all I want and then leave and everything is
fine (and the referenced mdb's lock file is generated and subsquently
deleted). However, the minute I open the form whose event procedures are
contained within the one module that contains calls from the referenced
mdb - when I leave my application, the problem occurs. Even if I don't call
any of the referenced mdb's functions!

I've tested this over and over again, and these results seem to be very
consistent. Is there some way to programmatically remove the reference so
this behavior doesn't occur? If I keep going in and out of the application,
I can end up getting many, many instances of Access hanging around.

Thanks,

JF
 
JF said:
I have an Access application in which I have a reference to another Access
.mdb file so I can use some of the latter mdb's functions.

The problem is, after leaving the main application, the referenced mdb
remains "open". That is, the ldb file still exists and if I go into the
Task Manager, the instance of MSACCESS.EXE is still alive.

Now, I've narrowed this problem down the specific instance where I load the
form that contains calls to the referenced mdb. So, I can open my main
application, move around in it all I want and then leave and everything is
fine (and the referenced mdb's lock file is generated and subsquently
deleted). However, the minute I open the form whose event procedures are
contained within the one module that contains calls from the referenced
mdb - when I leave my application, the problem occurs. Even if I don't call
any of the referenced mdb's functions!

I've tested this over and over again, and these results seem to be very
consistent. Is there some way to programmatically remove the reference so
this behavior doesn't occur? If I keep going in and out of the application,
I can end up getting many, many instances of Access hanging around.

Thanks,

JF
 
You don't want to "programmatically remove the reference so this behavior
doesn't occur". You want to find out what is causing the problem, and then
fix that cause!

There are several known causes of Access not closing down correctly. I don't
know whether these would affect a library, but it's certainly worth checking
them out.

- not closing (or setting to Nothing) DAO objects that you opened; for
example:
set rs = dbengine(0)(0).openrecordset (...)
...
set rs = nothing < NEEDED!

- referncing boolean controls or fields on a form, without explicitly naming
their Value property, or providing a comparison value:

if me!xxx then BAD
if me!xxx.value then OK
if me!xxx = true then OK
where xxx is any boolean control or field.

HTH,
TC
 
I agree with you 100% about finding the cause of the problem. The only
reason I mentioned programmatically removing the reference is because this
only started occurring when I added the other mdb as a reference. And, it
only occurs when the form that contains calls to the referenced mdb is
opened - even if I don't actually execute a single call to the referenced
mdb (ie, just bring up the form, and close it right away).

I'll check out your suggestions. I'm not opening any recordsets in any of
the objects in question, but there is an option group where I grab its value
without using the .Value property.
 
I located the source of the problem. When the form in question was loaded,
it called a function in a module that put the form in a global variable.
Then, when the form is unloaded, all I had to do was set this variable to
Nothing.

It's funny how the problem only manifested after I set a reference to
another mdb.
 
If it is NOT a standard coding problem, then there is a small
chance that it is a corrupt form or project. AFTER checking
your recordsets and control references, try recreating the
form as a new form, and /decompile both mdbs.

(david)
 
Well done & thanks for posting back.

TC


JF said:
I located the source of the problem. When the form in question was loaded,
it called a function in a module that put the form in a global variable.
Then, when the form is unloaded, all I had to do was set this variable to
Nothing.

It's funny how the problem only manifested after I set a reference to
another mdb.
 
Back
Top