Close all forms

  • Thread starter Thread starter Tara
  • Start date Start date
T

Tara

Is there a way to have any forms that are open close when
I click a single command button? Any number of forms
could be open at one time and I need a way to close all
of them at once, then re-open a specific one depending on
which command button is clicked.
Thanks!

Tara
 
You could add this in a module and run the function behind
a command button on click event

Routine: Close All Forms
Author:
JasonM

Description:
Closes all forms, takes an optional name to leave open

Example:

code:
Public Function CloseAllForms(Optional ByVal ExceptName As
String = vbNullString)
Dim i As Integer
Dim x As Integer

x = Forms.Count - 1

For i = x To 0 Step -1
If Forms(i).Name <> ExceptName Then
DoCmd.Close acForm, Forms(i).Name
End If
Next i
End Function

Chris
 
Back
Top