wineguy via AccessMonster.com said:
However, this did not close the main form which I suspect is the reason
the
back-end ldb file is open.
I checked to see if main form was still loaded: If IsLoaded("switchboard")
then I tried to force a close using docmd.close form but get the runtime
2501
error..
so it seems that I can't proceed with the backend compact until I can
close
the main switchboard.
any additional thoughts?
The above will not work....
Why?
Well, you can not call a un-bound form a form that is bound and then
close the calling form. It may look like the form is closed, but ms-access
will not have yet released the variable (internal memory) space.
This is just how the architecture of access works and how it reclaims
memory resource back.
it goes like this:
-----------> form1 with connection to BE
----------------> call form2 that is unbound
-----------------------> close 1st form.
So, we have an internal stack of:
-------------------
form1 |
------------------
form2 |
-------------------
When we close form1, the stack is:
-------------------
| <-form closed, but resources NOT YET returned to
------------------ pool of memory
form2 |
-------------------
It is ONLY when we close form 2 does the above WHOLE memory stack get
cleared out and return to the pool of memory for ms-access.
To see the above, close form2 (which is un-bound), and then re-open it, You
will now be able to compact from that form. So, at the end of the day you
CAN NOT CALL a un-bound form from a bound form, close it...and then hope
your connection will close..
I suppose you *could* try calling the 2nd form with a macro as opposed to a
code button, but I don't think the code stack will behave different.
Solution:
Well, call the compact routines from a un-bund form, and make sure that this
form was NOT called/opened by a form that is bound (else the bound form will
be "below" the memory stack of the next form...and again those resources
cannot be return until you empty that internal program stack.
Another solution and one I used for years is to call the compact routines
from a custom menu. That routine can then freely close all open (bound)
forms...and do the compact.
.....
if the macro idea works, do post back here....I not had time to try this,
but I quite sure it is the 2nd form loading on top of the interal memory
stack that prevents the conneciton resouces being killed...