Skip to Content
Former Member
Jan 26, 2011 at 08:51 PM

Crystal RDC - Subreports not counted in section


We are using craxdrt interface with C++ to run a Crystal Reports viewer. We are currently using CRXI but this was happening with CR 10. Years ago, our interface guru wrote ways to pass logon info to subreports. What the code did was to get the count of objects from an ISectionPtr and scan down till if found the crSubreportObject type object.

What was happening is that ISectionPtr::IReportObjectsPtr::GetCount() was was not counting the Subreport objects. If there were 5 field objects and a sub-report, it would return 5. If the section only contained a subreport object, it would return 0.

Here is a chunk of code:

ISectionPtr section = (*_m_pReport)->Sections->GetItem(sectionIdx);

IReportObjectsPtr pReportObjects = section->GetReportObjects();

long reportObjectsCount = pReportObjects->GetCount();

for (long idx = 1; idx <= reportObjectsCount; idx++) {

ReportObjectPtr pReportObject = pReportObjects->GetItem(idx);

if (pReportObject->GetKind() == crSubreportObject) {

// it's a subreport

ISubreportObjectPtr subReportObject = (ISubreportObjectPtr)pReportObject;

...anyway, this is where we put the login information bcause reportObjectsCount is 1 less than it should be, nothing happens to the subreport...

We have a workaround though -- but it is very strange. If we replace the Page Number special field in the page section with Page N of M, the count is correct!!

Is this a bug or is there something missing in that code to find the subreport?


-- John