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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unload Form

Status
Not open for further replies.

capone67

Programmer
Nov 6, 2000
115
CA
Hi Gang

Yet another problem I am encountering. I have a form with an OCX on it that can only be used by one form at a time. The environment I am working in will require me to use the OCX in two different circumstances. I have tried executing an Unload Form and receive no error messages but when my other application tries to access the same OCX it hangs because the OCX is not available.

Does anyone know how to get a form to truely unload?

Ken
 
When you Unload a form, only its displayed component is removed; the code associated with the form module does remain in memory.

To remove all traces of the form, set it to Nothing e.g. in the Unload event.

Set frmMyForm = Nothing _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
That's good advise. One additional point, make sure that is the last line of code executed in Form_Unload. If not, any reference to the form or a control or variable on it will cause a new instance of the form to load.
 
steve: what happens if you are in form1 and you want to see if form2 is active behind form1? I use:
If Form2.visible=true then DoSomething
Does this leave the form2 loaded and should you put
set form2=nothing in the first forms code to again remove it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top