Close all forms apart from current form

Derek

Registered User.
Local time
Yesterday, 23:35
Joined
May 4, 2010
Messages
234
I want to write a piece of code that will close any form apart from the current form.The following code doesn't work the way I want. Basically I want on the click event of the command button open up a relevant form but close other forms .

Code:
If  CurrentProject.AllForms("frm_LM_Home").IsLoaded Then

else
       DoCmd.Close acForm, me.name

 End If

Thanks
 
This isn't quite correct but it may help you get there
It SHOULD close all except the currently active form
However, it fails with popup forms

Code:
  Dim frm As Form
    For Each frm In Application.Forms
     If CurrentProject.AllForms(frm.Name).IsLoaded Then
        'close the form unless it's the currently active form
         If Screen.ActiveForm.Name <> frm.Name Then DoCmd.Close acForm, frm.Name
     End If
     DoEvents
    Next frm
 

Users who are viewing this thread

Back
Top Bottom