views:

82

answers:

1

I would like to obtain the name of a query behind a specific report. I was hoping to do something like this...

 Dim QueryName As String
 QueryName = CurrentProject.AllReports(MyReportName).RecordSource.Name

However, I know this does not work, but I would like to find a means of doing this. Is there something I am obviously overlooking?

+2  A: 

You have to open the report to get access to those kinds of properties.

Open in design mode so you don't actually run the thing.

Dim QueryName As String

DoCmd.OpenReport MyReportName, acViewDesign

QueryName = Reports(MyReportName).RecordSource

DoCmd.Close acReport, MyReportName
DJ
Works perfectly. Thanks,
Curtis Inderwiesche