1510982 - How to access the subreport information using the ReportDocument Object Model

SAP Knowledge Base Article - Public

1510982 - How to access the subreport information using the ReportDocument Object Model

Symptom

How to access the subreport information using the ReportDocument Object Model.


         

Environment

Visual Studio 2008

Crystal Reports 2008 Service pack 0 or above

Resolution

To get the subreport information the application has to access the subreport object traversing the main report sections.

Once the subreport object is accessed, the related information can be accessed by using the object properties.

Following sample code displays the name of the subreport using the 'name' property of the subreport object.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

Dim myReportDocument As New ReportDocument
myReportDocument.Load(Server.MapPath("report1.rpt"))
Dim mySections As Sections = myReportDocument.ReportDefinition.Sections
For Each mySection As Section In mySections
Dim myReportObjects As ReportObjects = mySection.ReportObjects
For Each myReportObject As ReportObject In myReportObjects
If myReportObject.Kind = ReportObjectKind.SubreportObject Then
Dim mySubreportObject As SubreportObject = CType(myReportObject, SubreportObject)
Dim subReportDocument As ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
Dim str As String = subReportDocument.Name
textbox1.text = str
CrystalReportViewer1.ReportSource = myReportDocument
End If
Next
Next
End Sub

Keywords

CR.Net, subreport info, sample, reportdocument , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1