Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    90

    Unanswered: Close all objects except one

    Hi,

    Is there an easy way to:

    a) Close all database objects? (i.e. all forms, reports etc)

    b) Close all database objects except one form?

    Using Access 2002.

    Thanks in Advance

    Steve

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Yes. You can use the following code to close all open Reports and Forms.

    Code:
        Dim intCounter As Integer
        
        On Error Resume Next
        
        For intCounter = 0 To Forms.Count - 1
            DoCmd.Close acForm, Forms(intCounter).Name
        Next intCounter
        
        For intCounter = 0 To Reports.Count - 1
            DoCmd.Close acReport, Reports(intCounter).Name
        Next intCounter
    To leave one open you will have to identify the one and then skip it when you are looping through the forms and reports.

    Or you can close them all and then re-open what you need.

  3. #3
    Join Date
    Feb 2004
    Posts
    90
    Thanks DCKunkle.

    It worked a treat!

    Last edited by Goldy; 08-03-06 at 17:06.

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    Sorry to but in, but this han't been reliable on my setups.

    Have a read here http://www.mvps.org/access/forms/frm0040.htm, should anomalities turn up (i e start at the othe end).
    Roy-Vidar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •