simple want when user click on close form button.all the form should close except Mdi form.but MDI Form also get close.Kindly let me know. any help would be Highly appreciated.here is the code what i have written.

Private Sub FrmClose_Click() 
Dim frm As Form 
 For Each frm In Forms 'it will loop until it finish all the form in a collection forms. 
   Unload frm 
  Next frm 
  End Sub

Several ways....

Dim F As Form, M As MDIForm
For Each F In Forms
  If F Is M Then
  Else
    Unload F
  End If
Next
Dim F As Form, M As MDIForm
For Each F In Forms
  If F.Name = "MDIForm1" Then
  Else
    Unload F
  End If
Next

and I could probably think of a few more but either one should do ya!


Good Luck

Standard Solution:

Dim objFrm As Form
For Each objFrm In Forms
    If [B]Not [/B]([B]TypeOf[/B] objFrm Is [B]MDIForm[/B]) Then
        Unload objFrm
    End If
Next

Standard Solution:

Thank You.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.