Document collections and AllForms collections 
Author Message
 Document collections and AllForms collections

I am a little confused by the documents collections and the allforms
collections.  I want to loop round all forms / reports and modules
picking out each module.

If I grab something from the forms collection it gives me a document
object.  How do I convert this to the form object I think I want.

What are the pros and cons of using the documents collections and the
allforms (and relatives) collections.

Thanks  
--
Andrew Black



Wed, 26 Mar 2003 03:00:00 GMT  
 Document collections and AllForms collections
Here is some code to loop through all reports and forms, and see if they
have a module, and also all modules:

SubsModules()
    Dim db As Database
    Dim ctr As Container
    Dim frm As Form
    Dim rpt As Report
    Dim mdl As Module
    Dim doc As Document
    Set db = DBEngine(0)(0)
    Set ctr = db.Containers!Modules
    For Each doc In ctr.Documents
        DoCmd.OpenModule doc.Name
        Set mdl = Modules(doc.Name)

        DoCmd.Close acModule, doc.Name, acSaveYes
    Next doc
    Set ctr = db.Containers!Forms
    For Each doc In ctr.Documents
        DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
        Set frm = Forms(doc.Name)
        If frm.HasModule = True Then

        End If
        DoCmd.Close acForm, doc.Name, acSaveYes
    Next doc
    Set ctr = db.Containers!Reports
    For Each doc In ctr.Documents
        DoCmd.OpenReport doc.Name, acViewDesign
        Set rpt = Reports(doc.Name)
        If rpt.HasModule = True Then

        End If
        DoCmd.Close acReport, doc.Name, acSaveYes
    Next doc
    Set ctr = Nothing
    Set db = Nothing
End Sub

I've left 3 blank lines for you to insert whatever code you want.

--
Jon

http://www.applecore99.freeserve.co.uk


Quote:
> I am a little confused by the documents collections and the allforms
> collections.  I want to loop round all forms / reports and modules
> picking out each module.

> If I grab something from the forms collection it gives me a document
> object.  How do I convert this to the form object I think I want.

> What are the pros and cons of using the documents collections and the
> allforms (and relatives) collections.

> Thanks
> --
> Andrew Black



Wed, 26 Mar 2003 03:00:00 GMT  
 Document collections and AllForms collections
However, AllForms can be nice if you want code that will work in an ADP
(which perhaps might be useful, some day).

--
MichKa

random junk of dubious value at the
multilingual http://www.trigeminal.com/ and
a new book on internationalization in VB at
http://www.i18nWithVB.com/


Quote:
> Here is some code to loop through all reports and forms, and see if they
> have a module, and also all modules:

> SubsModules()
>     Dim db As Database
>     Dim ctr As Container
>     Dim frm As Form
>     Dim rpt As Report
>     Dim mdl As Module
>     Dim doc As Document
>     Set db = DBEngine(0)(0)
>     Set ctr = db.Containers!Modules
>     For Each doc In ctr.Documents
>         DoCmd.OpenModule doc.Name
>         Set mdl = Modules(doc.Name)

>         DoCmd.Close acModule, doc.Name, acSaveYes
>     Next doc
>     Set ctr = db.Containers!Forms
>     For Each doc In ctr.Documents
>         DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
>         Set frm = Forms(doc.Name)
>         If frm.HasModule = True Then

>         End If
>         DoCmd.Close acForm, doc.Name, acSaveYes
>     Next doc
>     Set ctr = db.Containers!Reports
>     For Each doc In ctr.Documents
>         DoCmd.OpenReport doc.Name, acViewDesign
>         Set rpt = Reports(doc.Name)
>         If rpt.HasModule = True Then

>         End If
>         DoCmd.Close acReport, doc.Name, acSaveYes
>     Next doc
>     Set ctr = Nothing
>     Set db = Nothing
> End Sub

> I've left 3 blank lines for you to insert whatever code you want.

> --
> Jon

> http://www.applecore99.freeserve.co.uk



> > I am a little confused by the documents collections and the allforms
> > collections.  I want to loop round all forms / reports and modules
> > picking out each module.

> > If I grab something from the forms collection it gives me a document
> > object.  How do I convert this to the form object I think I want.

> > What are the pros and cons of using the documents collections and the
> > allforms (and relatives) collections.

> > Thanks
> > --
> > Andrew Black



Wed, 26 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Collections, Collections and More Collections

2. Creating a CDO collection from an Outlook collection

3. using collection of collections

4. Storing a collection in a collection

5. collection in collection

6. Migrating to System.Collections.IEnumerator from VB6.Collection

7. Persisting a Collection of a Collection

8. Collection of Collections?

9. Collections, swapping items in a collection

10. Collections of Collections..how?

11. collections of collections

12. Collection of Collections

 

 
Powered by phpBB® Forum Software