Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Melissa

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Close all forms in Access

Sometimes, it's necessary to close all forms in a single procedure:

   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  
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS