Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Set datasource for subreport

Hi, all,

I tried to add a subreport to a report document using inProc RAS, like so:

private CrystalDecisions.CrystalReports.Engine.ReportDocument document;

SubreportClientDocument subreportClientDocument;

reportClientDocument = document.ReportClientDocument;

subreportClientDocument = reportClientDocument.SubreportController.ImportSubreport("someName", pathToRPTFile, sectionWhereToAdd);

Later I wanted to set a datasource to the added subreport, but when looping through the main document, I get no subreports found.


CrystalDecisions.CrystalReports.Engine.ReportDocument subReport = document.Subreports[index];

document.Subreports has length of 0, although, I could sware it had worked

Strange thing is, later in the same code I do a loop,

  foreach (CrystalDecisions.CrystalReports.Engine.ReportObject reportObject in document.ReportDefinition.ReportObjects)


                if (reportObject.Kind == ReportObjectKind.SubreportObject)


            and it finds subreportObjects.

What am I doing wrong? And, how can I reach a given subreport, to set a datasource to it?

Thank you, all, in advance!

Former Member
Not what you were looking for? View more on this topic or Ask a question