Terminating the Class module

G

Guest

I have created a Class module for the first time in Microsoft Access
It works fine and does all intended work from another form.
Now in the end I want to do the cleaning up

I am having problems Terminating the Class.

Set objFTP= Nothing' FROM the calling for

Private Sub Class_Terminate(

' Clear object variables and unload the form

Unload gsFTPForm '''*** how to unload /// ERROR her
Set objFTP = Nothing ' No problem her
Set FTPForm = Nothing '' This also hangs up the code /// ERROR her

End Su

Queston 1. If I do not use the Terminate class should it matter much?

By the way There is no problem in initializin
Private Sub Class_Initialize(

' Create a new instance of the form holding th
' Internet Transfer Control

Set FTPForm = New Form_frmFT
Set objFTP = FTPForm.ctlInternet.Objec
End Su

Thanks
 
A

Albert D. Kallal

You could just let the form var go out of scope, and the form would close.
However, your desire to clean things up is likely a good idea.

There is no load, or un-load in ms-access (as compared to VB).

So, it is enough to set the form = nothing. You could add a custom close
method to the form...but I don't think you need it.

The only confusing I have here is are you using an instance of the class
object in the forms module code, or are you doing this else where? It would
not make sense to try and clean up the class object from within the form if
the form is not creating a instance of the object (so, there is a slight bit
of confusing here?).

If your code simply creates a instance of the object, and that object
creates a instance of the form, then You can use

frmGuiP.Visible = False
Set frmGuiP = Nothing

The above code would close the form, and then clean up quite nicely.
However, you can't do the above in the forms code that was initiated by the
same object!
Unload gsFTPForm '''*** how to unload /// ERROR here

As mentioned, we don't have a un-load, so, you can dump the above.
 
J

Jeetu

Thank you very much for this response. I have seen your
work on the Internet and it is a pleasure to correspond
with you.

Regarding the form var to go out of scope. That is a very
nice suggestion and it is comforting to know that it is a
good solution. I am interested in making all the code
lines work, if possible.

I am using the instance of the class module in a form
module.
Then my class module is using another form object which
has an Internet Control in it. This is the form object I
initialize in the class and want to close and set to
nothing when the Class is terminated.

Unload in Access Help says the following --
Removes an object from memory.
Syntax
Unload object

Thanks,
Jeetu
 

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

Top