SAP Knowledge Base Article - Public

1201977 - Fields are stripped from subreport that is based on Command Objects


When using Crystal Reports XI Release 2 and Visual Studio .NET, fields are stripped from the subreport when data is pushed to the report using ADO.NET objects.



To resolve, call SetDataSource on the subreport first, then set the main report"s data source. Fields will no longer be dropped from the subreport.
Basic code snippet:
Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument
'load the report
'loop through all the sections to find all the report objects
          For Each crSection In crSections
            crReportObjects = crSection.ReportObjects
            'loop through all the report objects to find all the subreports
            For Each crReportObject In crReportObjects
                If crReportObject.Kind = ReportObjectKind.SubreportObject Then
                    'you will need to typecast the reportobject to a subreport
                    'object once you find it
                    crSubreportObject = CType(crReportObject, SubreportObject)
                    'open the subreport object
                    crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
      'pass the dataset to the subreport(s)                   
                End If
'pass the dataset to the main report
'view the report
CrystalReportViewer1.ReportSource = crReportDocument


command table subreport data no stripped fields net , 5663534 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To


SAP Crystal Reports XI ; SAP Crystal Reports XI R2