Thanks for your response Allen. Figured it out for myself (quite easy
really).
I thought I would list it here in case anyone is interested.
Sub ListReports()
Dim filesys, fname, tstream
'query to return report names
' SELECT [Name] FROM MsysObjects WHERE ([Name] Not Like "~*") AND ([Type]
=
-32764)) ORDER BY [Name];
Set filesys = CreateObject("Scripting.FileSystemObject")
Set tstream = filesys.CreateTextFile("c:\temp\Reports.txt", True)
For Each r In CurrentProject.AllReports
tstream.writeline r.Name
Application.DoCmd.OpenReport r.Name, acViewDesign
For Each ctl In Reports(r.Name).Controls
If ctl.ControlType = acSubform Then 'subform/subreport
tstream.writeline " Sub Report - " & ctl.SourceObject
End If
Next
Application.DoCmd.Close acReport, r.Name, acSaveNo
Next
tstream.Close
Set filesys = Nothing
End Sub
Thanks again for the pointer
Ade
Adrian Turner said:
Can opening in Design view be done programmatically. An example showing
what
you suggest would be great. Thanks for the prompt reply.
Adrian
Allen Browne said:
To get a list of the reports in the database, loop through
CurrentProject.AllReports, or using a query like this:
SELECT [Name] FROM MsysObjects
WHERE ([Name] Not Like "~*") AND ([Type] = -32764))
ORDER BY [Name];
To programmatically discover which reports are subreports of others,
you
would need to open each report in design view, loop through the
Controls of
the Report until you find a subform/subreport control, and examine its
SourceObject to find out if it is a subreport. This isn't foolproof,
since
the Open event procedure of a report can assign something else to the
SourceObject of a subreport. Additionally, some reports may be opened
in
their own right as well as acting as a subreport.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Does anyone know of a way to compile a list of reports and more
importantly
which are subreports of other reports. We have an adp which could
with
some
housekeeping. A manual trawl seems a bit old fashioned. Any help
would be
appreciated.
Thanks
Adrian