List Report.RecordSource without opening report

W

Winshent

I want to list all report names within my current project along with
their corresponding recordsources.

The only examples i have seen require each report to be open. Is there
a way to do this with the report not being opened ?

Thanks

Vincent
 
F

fredg

I want to list all report names within my current project along with
their corresponding recordsources.

The only examples i have seen require each report to be open. Is there
a way to do this with the report not being opened ?

Thanks

Vincent

Sorry, the report must be open to get it's record source.
However, you can open it in design view, acHidden.


Public Sub GetRecordSource()
' Print out the RecordSource for each report.
Dim doc As Document
Dim cont As Container
With CurrentDb
For Each cont In .Containers
If cont.Name = "Reports" Then
For Each doc In cont.Documents
DoCmd.OpenReport doc.Name, acViewDesign, , , acHidden
Debug.Print "Report Name: " & doc.Name
Debug.Print "Record Source: " & Reports(doc.Name).RecordSource
Debug.print
DoCmd.Close acReport, doc.Name
Next doc
End If
Next cont
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top