Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close multiple forms 1

Status
Not open for further replies.

Techdawgs

Programmer
Nov 12, 2004
14
US
I have multiple forms open and they are all popup forms. I have a button on my current form that can close it so I can go back to the previous form, but I want to also put a button that would close it out and all the other popup forms.
 
Hi, bigdawgs,

Is it known which forms are open? IOW, when the user clicks the button, are you looking for "close whatever popup forms may be open" or "close formA, close formB, close formC"?

Ken S.
 
Basic idea, is to move through the forms collection, then close those you want to close...

[tt]dim idx as integer
dim intCount as integer
intCount=forms.count-1
for idx=intCount to 0 step-1
if forms(idx).name<>"frmNotToBeClosedForm" then
docmd.close acform, forms(idx).name
end if
next idx[/tt]

Roy-Vidar
 
How are ya bigdawgs . . . . .

The following closes all popups ([blue]no name referencing required[/blue]):
Code:
[blue]   Dim frm As Form, Ary, x
   
   For Each frm In Forms
      If frm.PopUp Then
         If Not IsEmpty(Ary) Then
            Ary = Ary & ";" & frm.Name
         Else
            Ary = frm.Name
         End If
      End If
   Next
         
   Ary = Split(Ary, ";")
   
   For x = LBound(Ary) To UBound(Ary)
      DoCmd.Close acForm, Ary(x)
   Next[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top