How to close all open forms

mitchem1

Registered User.
Local time
Yesterday, 21:27
Joined
Feb 21, 2002
Messages
153
I have a button called Smart Search that is available on almost all forms in my db. Is there a way that when the button is clicked, it will not only open the Smart Search form, but will close all other forms currently open. Thank you.
 
M,

Something like this should get you close...

Code:
Docmd.openform "FrmSmartSearch"

Dim obj As AccessObject, dbs As Object

    Set dbs = Application.CurrentProject

    For Each obj In dbs.AllForms
        If obj.IsLoaded = True Then
            If obj.Name <> "FrmSmartSearch" Then
                DoCmd.Close acForm, obj.Name
            End If
        End If
    Next obj

Regards,
Tim
 
Thanks, I'll give it a shot.
 

Users who are viewing this thread

Back
Top Bottom