Unloading a form

this is all the points i have.... i have a form. when it unloads it misteriously reapers. how do i keep this form happening. why does the form show up after it reloads. is this because there is an event from the form taht is staill in effect?
hessAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crazymanCommented:
Post the code you are using to close the form and any code in the form load
0
vgruCommented:
The reason the form keeps reappearing is that you must be calling a method or function in that form from another form.

Any reference you make to any control or procedure in that form from another form will re-load the form after you unload it.
0
mcriderCommented:
hess,

Vgru's answer is not complete, and doesn't solve your problem...

You CAN call a procedure in your form and not have it display.  What you have to be careful about is that in the procedures that you call, you don't show the form.

Also, any time you call a procedure on a form and the form is not currently loaded, the FORM_LOAD event will fire...
If you have a Form.Show or a Me.Show in the FORM_LOAD event, then the form will be displayed, even though you didn't intend to have the form display...

Also remember, when you are ending your program, do this:

Dim X As Object
For Each X In Forms
    Unload X
Next

Hope this helps!


Cheers!
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

caraf_gCommented:
And I'll add to that....

Unload Form1 '<Form1 is unloaded here... but...

Form1.Show ' - this creates a new instance of Form1. And Form1 is reloaded.
or
Form1.SomeControl.SomeProperty = SomeValue ' - this also creates a new instance of Form 1

but
Call Form1.SomeSub(SomeParameters) 'is fine, as long as inside SomeSub you don't refer to properties of Form1 or one of its controls.
0
Éric MoreauSenior .Net ConsultantCommented:
>>but
Call Form1.SomeSub(SomeParameters) 'is fine, as long as inside SomeSub you don't refer to properties of Form1 or one of its controls.<<

If this is the case, this sub have nothing to do there!!!
0
caraf_gCommented:
Ah, very true, but that is a different issue altogether ;-)
0
caraf_gCommented:
Hm... on the other hand though, the sub may be manipulating module level variables of the Form1 module.

<playing devil's advocate>
0
Éric MoreauSenior .Net ConsultantCommented:
Module level variables becomes Form's properties.
0
caraf_gCommented:
DOH!

Of course....

I'll modify my statement:

Whenever you refer to anything to do with Form1, the "object" Form1 is instantiated. But only if you refer to window or control properties of Form1, a window is created for Form1.
0
caraf_gCommented:
To illustrate this, create a project with two forms, form1 and form2. Stick a command button on form1.

Paste the following code in form2:
Option Explicit
Public SomePublicVariable As String
Private Sub Form_Initialize()

MsgBox "I'm instantiated"

End Sub

Private Sub Form_Load()

MsgBox "I'm loaded"

End Sub



Paste the following code in Form1
Option Explicit

Private Sub Command1_Click()

MsgBox "Set a public variable on form2 but don't touch any window properties"
Form2.SomePublicVariable = "hi"

MsgBox "Set a window properties on form2"
Form2.Caption = "hi too"

End Sub

0
hessAuthor Commented:
I"m here but i just woke up and have to go to work. thank you for all of your input. i'll try this code out tonight. thankyou.

Jon
0
AndySulzCommented:
put End in the Form_Unload ()
0
hessAuthor Commented:
I have multiple forms. i dont' want to end the application
0
Éric MoreauSenior .Net ConsultantCommented:
On december 22, you said that you were to try the code.

So where are you now?
0
AndySulzCommented:
do a form.visible = false in it then
0
caraf_gCommented:
That way you'll end up with loads of forms loaded in memory but not visible. A really bad suggestion.
0
mcriderCommented:
Hess,

Did you try my original solution adding the following to the FORM_UNLOAD event:

Dim X As Object
For Each X In Forms
    Unload X
Next


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.