Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    Unanswered: closing all loaded forms in code

    ok guys - access 97 so allforms does not work

    Public Function closeforms()
    On Error Resume Next
    Dim obj As Object
    For Each obj In Application.Forms
    DoCmd.close acForm, obj.Name

    Next obj

    End Function

    only closes one form at a time not all of the opened forms

    should I approach this differently and enumerate throught the collection and then use the isloaded function to see if it is loaded and then "close acform" if it is
    Dale Houston, TX

  2. #2
    Join Date
    Feb 2004
    Posts
    137
    Try:
    Code:
    Public Function closeforms()
     
     Dim X As Long
     
        For X = Forms.Count To 1 Step -1
            DoCmd.Close acForm, Forms(X - 1).Name
        Next X
     
    End Function

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5

    Awesome

    most helpful 4 lines of code I have used in awhile

    I have done this for 97 before but I just could not remember where I had this snippett - excellent code and response - thank you
    Dale Houston, TX

Posting Permissions

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