close all child forms before closing parent form????? 
Author Message
 close all child forms before closing parent form?????

I've an Access97  "Parent" form that users use as a switchboard to
navigate to other "Child" forms. I'd like to put some code in so that
you cannot close the parent form without closing the child forms.

At the moment, I'm using the If IsLoaded(frmname) function on the Unload
property on the Parent form. I'm having a line of code for each child
form, so that if a child form is loaded, it gets closed before the
parent form is closed.

Is there a more efficient way to do this at all, as I reckon this must
is a bit of a bad 'fudge'??!!

Any help would be much appreciated.

cheers

bob



Fri, 16 Mar 2001 03:00:00 GMT  
 close all child forms before closing parent form?????
If the Parent form shouldn't be closed while any other form is open then
just check Forms.Count (if it's >1 then there is another form open).

Alternatively if it is just a particular list of forms you could use this
function

Function AreFormsLoaded(ParamArray FormsList()) As Boolean
'*******************************************
'Name:        AreFormsLoaded (Function)
'Purpose:     Detect if any form in a list _
              of forms is open
'Date:        28 September 1998
'Called by:   Any
'Calls:       None
'Inputs:      FormsList - Array of form names _
              passed as a comma delimited list
'Output:      True if any one form in FormsList _
              is open. _
              False if none of the forms is open
'*******************************************
  Dim intLbound As Integer
  Dim intUbound As Integer
  Dim intX As Integer
  Dim blnRet As Boolean
  Dim loForm As Form

  intLbound = LBound(FormsList)
  intUbound = UBound(FormsList)
  blnRet = False
  For Each loForm In Forms
    For intX = intLbound To intUbound
      If loForm.Name = FormsList(intX) Then
        blnRet = True
        Exit For
      End If
    Next
    If blnRet = True Then Exit For
  Next
  AreFormsLoaded = blnRet
End Function

You would call it from the form unload event as follows
Private Sub Form_Unload(Cancel As Integer)
  Cancel = AreFormsLoaded("frmExplainWiz", "wz_frm_About")
End Sub

Quote:

>I've an Access97  "Parent" form that users use as a switchboard to
>navigate to other "Child" forms. I'd like to put some code in so that
>you cannot close the parent form without closing the child forms.

>At the moment, I'm using the If IsLoaded(frmname) function on the Unload
>property on the Parent form. I'm having a line of code for each child
>form, so that if a child form is loaded, it gets closed before the
>parent form is closed.

>Is there a more efficient way to do this at all, as I reckon this must
>is a bit of a bad 'fudge'??!!

>Any help would be much appreciated.

>cheers

>bob



Fri, 16 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Parent forms are cropped after opening/closing child forms

2. Call a parent form function when the child is closing

3. Add Record OnClick Action closes both Child and (Grand)Parent forms

4. Prevent parent form closing whild child is open

5. Closing a form when other form is opening but reopening when all forms closed

6. linking parent form to child form without going the form/subform route

7. event in parent after child closed

8. Autnumber a child form for each new parent forms

9. fairly Newbie: how to get child forms to update parent form

10. link child form to parent form opened via recordset


 
Powered by phpBB® Forum Software © phpBB Group