Unloading MDI Child Forms 
Author Message
 Unloading MDI Child Forms

I have a MDI based application. Various forms are loaded from the parent's
menu bar. There are certain circumstances when I wish not to have two
particular child forms open at once. I've tried to use the
mdiform.activeform.name(etc) to determine whether a particular child is
active. Unfortunately I get an object not set for the first time a child
form is loaded. i.e. no previous active form.

Is there a cleaner way to detect what form is open if any so that I can then
close it prior to opening another child.

Thanks



Thu, 27 Apr 2000 03:00:00 GMT  
 Unloading MDI Child Forms

Hi Bob:

Quote:
>Is there a cleaner way to detect what form is open if any so that I can
then
>close it prior to opening another child.

You could loop thru the Forms collection, i.e.

Public Sub CloseOtherChildForms(frmChild As Form)
  Dim frm As Form
  For Each frm In Forms
    If frm.Name = frmChild.Name Then
      If frm Is frmChild = False Then
        Unload frm
      End If
    End If
  Next frm
End Sub

Hope this helps,

Doug.



Fri, 28 Apr 2000 03:00:00 GMT  
 Unloading MDI Child Forms

Bob

I think you're on the right track with (in the parent):

Unload Me.ActiveForm

The first time through this will fail (with error 91) - so allow that
error! (or have a first-time flag).

Regards
{*filter*}



Sat, 29 Apr 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Unload MDI Child forms

2. Unloading MDI Child Forms

3. Q: Form activate Fires On Non Child MDI Forms But Only Once On Child Mdi Forms

4. MDI Help - Prevent Child Form from Exiting in Unload Event

5. GPF in Krnl386.exe crashes VB5 IDE on unload of MDI child form

6. MDI Help - Prevent Child Form from Exiting in Unload Event

7. Modifying object in MDI Parent form from MDI Child form

8. Make a reference to a MDI form with a reference of a MDI child form

9. MDI-Child form and positon on MDI-form

10. Developing OLE MDI Child forms displayed on Control MDI Form

11. MDI child forms on top of a picture on a MDI form

12. Help with MDI Forms and MDI child forms

 

 
Powered by phpBB® Forum Software