Close all forms in Access
1 2 Function CloseAllForms() 3 4 'It will close all forms before opening the new form (if required) 5 6 Dim obj As Object 7 Dim strName As String 8 9 For Each obj In Application.CurrentProject.AllForms 10 DoCmd.Close acForm, obj.name, acSaveYes 11 Next obj 12 13 End Function
Close all forms - except one particular screen:
1 2 Function CloseAllForms() 3 4 5 Dim obj As Object 6 Dim strName As String 7 8 For Each obj In Application.CurrentProject.AllForms 9 10 If obj.Name <> "Your Form" Then 11 12 DoCmd.Close acForm, obj.name, acSaveYes 13 14 End if 15 Next obj 16 17 End Function 18