Home All Groups Group Topic Archive Search About
Author
21 Nov 2007 4:23 AM
Jack
2 forms: Form1 and Form2

Form2 has cmdCancel button:
Public Sub cmdCancel_Click()
    Call EndAll  ===> this call unloads Form1
     Unload Me
End Sub

Form1 Unload event:
Private Sub Form_Unload(Cancel As Integer)
Dim f As Form
  For Each f In Forms
    Unload f
  Next
End Sub

Clicking on cmdCancel causes the application termination.
My question is:
Why Form2 does not go through Form_Unload (for the second time)? Is that
always true?
If the form is unloaded Unload Me does not affect anything?
Thanks,
Jack

Author
21 Nov 2007 4:48 AM
Steve Gerrard
"Jack" <replyto@it> wrote in message
news:ulNQTZ$KIHA.1324@TK2MSFTNGP06.phx.gbl...

> If the form is unloaded Unload Me does not affect anything?

Correct.
Author
21 Nov 2007 9:08 AM
Jan Hyde (VB MVP)
"Jack" <replyto@it>'s wild thoughts were released on Tue, 20
Nov 2007 23:23:52 -0500 bearing the following fruit:

Show quoteHide quote
>2 forms: Form1 and Form2
>
>Form2 has cmdCancel button:
>Public Sub cmdCancel_Click()
>    Call EndAll  ===> this call unloads Form1
>     Unload Me
>End Sub
>
>Form1 Unload event:
>Private Sub Form_Unload(Cancel As Integer)
>Dim f As Form
>  For Each f In Forms
>    Unload f
>  Next
>End Sub
>
>Clicking on cmdCancel causes the application termination.
> My question is:
>Why Form2 does not go through Form_Unload (for the second time)? Is that
>always true?
>If the form is unloaded Unload Me does not affect anything?
>Thanks,
>Jack
>

My question would be why is the form unload there at all. It
only confuses anyone reading the code. It implies EndAll
doesn't close this particular form.


--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde