Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Q and A _ Close All Objects

Posted by: rzw0wr Feb 13 2020, 10:13 PM

Is there any way to close all objects at one time?

Is there a VBA way to use the Close All command like on the form close dialog box?

I have searched the internet but all of the code and explanations are over my head.


Thank you,
Dale

Posted by: theDBguy Feb 13 2020, 10:30 PM

Hi Dale. Which "objects" are you referring to? Is there a button for it now? If so, which one is it?

Posted by: rzw0wr Feb 13 2020, 10:36 PM

Forms and reports.

No button I want to do it when the main menu form opens.

This is what I am using now.
It works but it does not close all the open forms.

CODE
Private Sub Form_Current()

Dim rpt As Report
Dim frm As Form

  For Each rpt In Application.Reports
    DoCmd.Close acReport, rpt.Name
  Next rpt
  For Each frm In Application.Forms
    If frm.Name <> "frmAAAAMain" Then
        DoCmd.Close acForm, frm.Name
    End If
    
  Next frm
  
End Sub


Thanks,
Dale

Posted by: theDBguy Feb 13 2020, 10:40 PM

Okay, see if https://www.UtterAccess.com/wiki/CloseAllForms can help get you started in the right direction.

Posted by: rzw0wr Feb 13 2020, 10:47 PM

Well, I guess that wasn't too confusing.

Thanks for the link.
I will give it a try.

Thanks again DBguy, It appears to work just fine.

Thank you,
Dale

Posted by: theDBguy Feb 13 2020, 11:28 PM

Hi. You're welcome. Good luck with the rest of your requirements.