[AccessD] A2K: Loop through Forms and close open forms

Darren DICK d.dick at uws.edu.au
Tue Jun 1 20:23:58 CDT 2004


Hi Glen
No I worked it out and rolled my own fro you code
What I needed was the line...
"dbsCurrent.Containers("Forms").Documents"

Thanks heaps 

Darren
What I came up with is below

Function f_CloseAllForms()

On Error GoTo Err_f_CloseAllForms

Dim objTmp As Object
    Dim db As Database
    Dim strName As String
    
    Set db = CurrentDb
    
    For Each objTmp In db.Containers("Forms").Documents
        strName = objTmp.Name
           ' If strName <> "frmSwitchboard" Then
                If IsLoaded(strName) Then
                    DoCmd.Close acForm, strName, acSaveNo
                End If
            'End If
    Next objTmp

Exit_f_CloseAllForms:
Exit Function

Err_f_CloseAllForms:
MsgBox Err.Number & " " & Err.Description, vbCritical, "error in f_CloseAllForms module"
Resume Exit_f_CloseAllForms

End Function


----- Original Message ----- 
From: "Glen McWilliams" <glen_mcwilliams at msn.com>
To: <accessd at databaseadvisors.com>
Sent: Wednesday, June 02, 2004 11:07 AM
Subject: Re: [AccessD] A2K: Loop through Forms and close open forms


> Darren
> 
> Do you have an equalvalent function to my gfnIsObjectOpenBln function? Let 
> me know and I will send it. Sorry I forgot it.
> 
> Glen
> >From: "Darren DICK" <d.dick at uws.edu.au>
> >Reply-To: Access Developers discussion and problem 
> >solving<accessd at databaseadvisors.com>
> >To: "Access Developers discussion and problem 
> >solving"<accessd at databaseadvisors.com>
> >Subject: Re: [AccessD] A2K: Loop through Forms and close open forms
> >Date: Tue, 1 Jun 2004 12:06:03 +1000
> >
> >Glen
> >Many many thanks
> >Just what I needed
> >Many thanks
> >
> >Darren
> >
> >----- Original Message -----
> >From: "Glen McWilliams" <glen_mcwilliams at msn.com>
> >To: <accessd at databaseadvisors.com>
> >Sent: Tuesday, June 01, 2004 11:10 AM
> >Subject: RE: [AccessD] A2K: Loop through Forms and close open forms
> >
> >
> > > Darren
> > >
> > > Here is a snippet from my shut-down module, which walks through the 
> >Forms
> > > collection closing any open form:
> > >
> > > '****Begin Code****
> > >    ' Close any open Forms.
> > >    ' Loop through the Forms collection.
> > >    For Each objTmp In dbsCurrent.Containers("Forms").Documents
> > >       ' Assign the name propery value, for each Form, to the Name string
> > > variable.
> > >       strName = objTmp.Name
> > >       If gfnIsObjectOpenBln(acForm, _
> > >                             strName) Then
> > >          ' Use the Close method of the DoCmd object to close the 
> >specified
> > > object.
> > >          DoCmd.Close acForm, strName
> > >       End If
> > >    ' Repeat the foregoing block of statements for the next element in 
> >the
> > > specified
> > >    ' collection.
> > >    Next objTmp
> > > '****End Code****
> > >
> > >
> > > >From: "Darren DICK" <d.dick at uws.edu.au>
> > > >Reply-To: Access Developers discussion and problem
> > > >solving<accessd at databaseadvisors.com>
> > > >To: "AccessD List" <AccessD at databaseadvisors.com>
> > > >Subject: [AccessD] A2K: Loop through Forms and close open forms
> > > >Date: Tue, 1 Jun 2004 09:46:57 +1000
> > > >
> > > >Hello all
> > > >
> > > >I want to loop through the Forms collection and close any form/forms 
> >that
> > > >is/are open.
> > > >
> > > >Any suggestions?
> > > >
> > > >Many thanks in advance
> > > >
> > > >Darren
> > > >
> > > >--
> > > >_______________________________________________
> > > >AccessD mailing list
> > > >AccessD at databaseadvisors.com
> > > >http://databaseadvisors.com/mailman/listinfo/accessd
> > > >Website: http://www.databaseadvisors.com
> > >
> > >
> > > --
> > > _______________________________________________
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> >--
> >_______________________________________________
> >AccessD mailing list
> >AccessD at databaseadvisors.com
> >http://databaseadvisors.com/mailman/listinfo/accessd
> >Website: http://www.databaseadvisors.com
> 
> 
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list