Almost certainly the problem is that your code isn't cleaning up properly.
Yes you need to unload your forms. Hard to make specific suggestions about
code structure; but better than 'Unload me' within the form is for the
calling code to take care of it, eg ---
Dim pForm as frmMyForm
Set pForm = new frmMyForm
pForm.Show
unload pForm
Set pForm = nothing
In other words, treat all forms as objects: instantiate them and destroy
them as needed. A basic prinicple of object-oriented coding is that objects
are never responsible for their own lifespans. Thus a form should never try
to destroy itself.
Hi Jezebel,
Thanks!
Right, is must be my pure garbage collection skills.
I now have the following code:
Dim pForm As UserFormTUSKrav
Private Sub Document_New()
Set pForm = New UserFormTUSKrav
pForm.initUserFormTUSKrav
Unload pForm
Set pForm = Nothing
End Sub
Private Sub Document_Close()
Set pForm = New UserFormTUSKrav
pForm.initUserFormTUSKrav
pForm.saveDoc
Unload pForm
Set pForm = Nothing
End Sub
But I still get the same error message – “out of memory”… when several
instances of the template has been run.
Any ideas?
/Jes
"Jezebel" skrev:
> Almost certainly the problem is that your code isn't cleaning up properly.
> Yes you need to unload your forms. Hard to make specific suggestions about
[quoted text clipped - 13 lines]
> are never responsible for their own lifespans. Thus a form should never try
> to destroy itself.
Jezebel - 17 Feb 2006 21:07 GMT
Put a messagebox or debug.print statement in the form's Terminate event, and
check that it really does terminate. (And similarly for any class modules
you may have.) The sorts of things that will form from unloading are
variables that point to objects on the form itself -- such as a variable
containing a reference to a form control.
> Hi Jezebel,
>
[quoted text clipped - 49 lines]
>> try
>> to destroy itself.