0

My report combines two independent reports together. The main report has no data sources, but the two subreports use the same three-table dataset.

How can I resolve this error that I get from running the code below?

Object reference not set to an instance of an object

objRpt = New rptOVERDET
objRpt.SummaryInfo.Dispose()
objRpt.Subreports("srOverview").SetDataSource(dsDetail)
objRpt.Subreports("srOverview").SummaryInfo.Dispose()
objRpt.Subreports("srOverview").SummaryInfo.ReportComments = "Overview Report" & Trim(strReportHeader) & vbNewLine & Trim(strContactPhone)

objRpt.Subreports("srDetail").SetDataSource(dsDetail)
objRpt.Subreports("srDetail").SummaryInfo.Dispose()
objRpt.Subreports("srDetail").SummaryInfo.ReportComments = "Detail Report" & Trim(strReportHeader) & vbNewLine & Trim(strContactPhone)
4444
  • 3,541
  • 10
  • 32
  • 43
EddiRae
  • 47
  • 8
  • You still have to set the data source on the main report. You may not need to set the sub report datasets at all. Also, don't make any of those dispose calls until after the report is loaded, and you only do that on the main report. – reckface Jun 19 '17 at 20:48
  • No matter how many subreports you have the important is how do you construct your query? see this https://stackoverflow.com/questions/41810978/query-from-two-tables-in-report/41819099#41819099 – Vijunav Vastivch Jun 20 '17 at 00:20
  • https://stackoverflow.com/questions/2099131/how-can-we-pass-a-parameter-from-main-report-to-subreport-in-crystal-reports-xi – Vijunav Vastivch Jun 20 '17 at 00:22
  • I am getting the following error An unhandled exception of type 'CrystalDecisions.CrystalReports.Engine.DataSourceException' occurred in CrystalDecisions.CrystalReports.Engine.dll Additional information: The report has no tables. I changed the code to be as follows: – EddiRae Jun 20 '17 at 17:47
  • objRpt = New rptOVERDET objRpt.SetDataSource(dsDetail) objRpt.SummaryInfo.Dispose() objRpt.Subreports("srOverview").SummaryInfo.ReportComments = "Overview Report" & Trim(strReportHeader) & vbNewLine & Trim(strContactPhone) Dim ds As DataSet = New DataSet() objRpt.Subreports("srDetail").SummaryInfo.ReportComments = "Detail Report" & Trim(strReportHeader) & vbNewLine & Trim(strContactPhone) – EddiRae Jun 20 '17 at 17:50
  • reds, I have the queries working correctly. These were reports that are currently standalone reports now. We were combining them so that they could view the overview and detail information as a browse on their computer. – EddiRae Jun 20 '17 at 17:53

0 Answers0