close all forms except 1 but not if dirty

shutzy

Registered User.
Local time
Today, 20:28
Joined
Sep 14, 2011
Messages
775
i am wanting to close all forms on timer event. all forms except one. also if any form is dirty then i do not want to even start running the vba.

i have seen a thread that gives me the code to close all forms except listed but im not sure about getting access to look at all the forms first, see if any are dirty then exit sub

the main reason for this is my staff sometimes do not log out. and for audit trails this can be bad. who's done what when and where.

the code for closing all forms
Code:
'This code closes all open forms in the current project and then opens the named form in quotations
Dim obj As Object
Dim strName As String
For Each obj In Application.CurrentProject.AllForms
Debug.Print obj.Name
If obj.Name = "StartFilter" Then

Else
DoCmd.Close acForm, obj.Name, acSaveNo
End If
Next obj


thanks
 
Code:
If obj.Name = "StartFilter" Then

ElseIf obj.Dirty Then
   Exit Sub
Else
   DoCmd.Close acForm, obj.Name, acSaveNo
End If
 

Users who are viewing this thread

Back
Top Bottom