Close all open forms

D

Dirk Goldgar

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
 
G

Guest

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)


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top