Report Recordsouce

J

JimS

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?
 
J

John Spencer

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..
 

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