Function to loop all open forms and, if they’re in design mode, close them. Default save behavior is to prompt for save.
' CloseDesignForms
' http://www.utteraccess.com/wiki/index.php/CloseDesignForms
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev date brief descripton
' 1.0 2013-08-30
Function CloseDesignForms()
Dim frm As Object
Dim count As Long
count = 0
For Each frm In CurrentProject.AllForms
If IsOpen(frm.Name, acForm) Then
If frm.CurrentView = 0 Then
DoCmd.Close acForm, frm.Name
count = count + 1
End If
End If
Next
If count > 0 Then
MsgBox (count & " forms closed")
Else
MsgBox ("No forms to close")
End If
End Function