水晶报表子报表显示问题
我的一个水晶报表中包含一个子报表,可在VB程序每次预览时都提示子报表登录失败,但在水晶报表软件中预览时正常显示,不知道这样如何解决?
------解决方案--------------------
'显示子报表
Function showSubReport(ByVal mainReport As ReportClass, ByVal Ds As DataSet, ByVal TableName As String, ByVal SubReportControlName As String)
'Dim SubReport As New ReportDocument()
'SubReport = mainReport.OpenSubreport(SubReportName)
Ds.Tables(0).TableName = TableName
'SubReport.SetDataSource(Ds)
'SubReport.Refresh()
Dim subreportName As String
Dim subreportObject As SubreportObject
Dim subreport As New ReportDocument()
If TypeOf (mainReport.ReportDefinition.ReportObjects.Item(SubReportControlName)) Is SubreportObject Then
subreportObject = mainReport.ReportDefinition.ReportObjects.Item(SubReportControlName)
' 获取子报表名称。
SubReportName = SubreportObject.SubreportName
' 打开子报表作为 ReportDocument。
subreport = SubreportObject.OpenSubreport(SubReportName)
' 预览子报表。
subreport.SetDataSource(Ds)
subreport.Refresh()
End If
End Function