Close all forms in Access
Function CloseAllForms() 'It will close all forms before opening the new form (if required) Dim obj As Object Dim strName As String For Each obj In Application.CurrentProject.AllForms DoCmd.Close acForm, obj.name, acSaveYes Next obj End Function
Close all forms - except one particular screen:
Function CloseAllForms() Dim obj As Object Dim strName As String For Each obj In Application.CurrentProject.AllForms If obj.Name <> "Your Form" Then DoCmd.Close acForm, obj.name, acSaveYes End if Next obj End Function