Close all open forms

  • Thread starter Thread starter David
  • Start date Start date
David said:
How do I close all open forms, with the exception of
FrmHidden
FrmMain

This ought to do it:

' Close all open forms except "FrmHidden" and "FrmMain"
For lngX = Forms.Count - 1 To 0 Step -1
With Forms(lngX)
If .Name = "FrmHidden" _
Or .Name = "FrmMain" _
Then
' Spare this one
Else
DoCmd.Close acForm, .Name
End If
End With
Next lngX
 
Thanks Dirk
-----Original Message-----


This ought to do it:

' Close all open forms except "FrmHidden" and "FrmMain"
For lngX = Forms.Count - 1 To 0 Step -1
With Forms(lngX)
If .Name = "FrmHidden" _
Or .Name = "FrmMain" _
Then
' Spare this one
Else
DoCmd.Close acForm, .Name
End If
End With
Next lngX

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Back
Top