
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