Report Recordsouce

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to interrogate the recordsource of a report (that is not loaded) so I
can offer to export that query to excel for the user...

Basically, he picks a report he wants exported to excel. I need to find out
what query that's based on, then export that query to an excel file for him.

How do I find out what query a report is based upon? (Isn't that the
recordsource property?) Must I load the report first?
 
I believe that you will have to load the report to determine its record
source. You can load the report in design mode and grab the recordsource
property and then close the report. If you want to hide the flashing of
the report, you could use DoCmd.Echo False and DoCmd.Echo True to keep the
user from seeing the flash.

Something like the following UNTESTED AIRCODE

Public Function getsource(strReportName)
On Error GoTo OOOPS
DoCmd.Echo False
DoCmd.OpenReport strReportName, acViewDesign

getsource = Reports(strReportName).RecordSource
DoCmd.Close acReport, strReportName

OOOPS:
DoCmd.Echo True

End Function

NOTE that this has no real error handling. Just one bit to make sure that
screen drawing is turned back on..
 
Back
Top