Skip to Content
0

Cryatal Reports for Visual Studio change on second sureport not saved

Feb 07, 2017 at 03:57 PM

25

avatar image

Hi, I have a program che cycle on all subrerports of a reports and make some changes on a fields. After I save the report but only changes on first subrport are saved. The program is like follow code. The function : CheckFieldMapping remove some fields with report.ReportDefController.ReportObjectController.Remove(rptObject).

report = New CrystalDecisions.CrystalReports.Engine.ReportDocument

report.Load(strFile, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)

Dim rdc As ISCDReportClientDocument

rdc = report.ReportClientDocument

For Each subReportName As String In subReportNames

Dim subrptObj As SubreportClientDocument

subrptObj = dc.SubreportController.GetSubreport(subReportName)

CheckFieldMapping(rdc.DisplayName, CType(subrptObj, ISCRSubreportClientDocument)) subrptObj = Nothing

Next

subReportNames.RemoveAll()

rdc.Save()

report.SaveAs(strFile, False) rdc.Close() rdc = Nothing

Same idea ?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Don Williams
Mar 16, 2017 at 05:43 PM
0

Hi Filippo,

Try saving the report after each subreport change and then compare output in CR Designer.

Or open the subreport rather than just loading it into memory...

Something like this:

foreach (CrystalDecisions.CrystalReports.Engine.Section section in rpt.ReportDefinition.Sections)
{
foreach (CrystalDecisions.CrystalReports.Engine.ReportObject reportObject in section.ReportObjects)
{
if (reportObject.Kind == ReportObjectKind.SubreportObject)
{
CrystalDecisions.CrystalReports.Engine.SubreportObject subReport = (CrystalDecisions.CrystalReports.Engine.SubreportObject)reportObject;

CrystalDecisions.CrystalReports.Engine.ReportDocument subDocument = subReport.OpenSubreport(subReport.SubreportName);

.... your code


subDocument.SetDataSource(ds);
}
}
}

Don

Share
10 |10000 characters needed characters left characters exceeded