
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