How to close a Form object?

P

Patrick386

Hello!

if I have created an object Form1 of type myForm as follow:
SET Form1 = New myForm

Where Form1 is Declared in a module as public like follow:
Public Form1 AS myForm

The problem that I am facing is that when I clear the object using
Fomr1 = Nothing in a procedure of closing put inside myForm

this object is only hidden and when I check with IF Form1 Is Nothing Then ...the test always says that it is not equal to Nothing after the first time that I've set the object. I need to open the form 'myForm' in Design View to clear all the object attached to this form.

I cannot use the function DoCmd.Close acForm, me.Name because I have many instances of myForm opened at the same time. and if I close "myForm", it will close the first one opened.

So how can I reset the object completely form the memory?

Thanks for any suggestion
Best regards
 
A

Albert D. Kallal

The normal approach here is simply to execute a docmd.Close without any
parameters.

(and, a user can click on the "x" to close also)

The above does assume that the form will have to have the focus. I as a
habit do prefer your original syntax of:

DoCmd.Close acForm, me.Name

The above is more reliable, and is subject to less focus bugs/problems then
using just docmd.Close

However,

docmd.Close

Should work just fine in most cases.

Further, if the form does not have the focus, then it likely that "other"
code that is trying to close the form, and your use of formVAR = nothing
should work as long as the code is not executed inside of the form.
 
P

Patrick386

Is this picture from you?
members.shaw.ca/AlbertKallal/Articles/cas3.jpg
Sorry, I'm not spying on you, but only curious..
 

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