SAP Knowledge Base Article - Public

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


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



Visual Studio 2008

Crystal Reports 2008 Service pack 0 or above


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
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
End Sub


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


Crystal Reports 2008 V1