Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

Multiple Subreports

I am using Crystal Reports v10 that shipped with Visual Studio 2005. I'd like to have two subreports in the main reports. However, when I insert second subreport, the main report will not work. The main report will work fine when it has only one report. I inserted two subreports in different group section headers.

Here is how I set the datasource for each subreport:
            Dim reportPath As String = Server.MapPath("Report/Main.rpt")
            finalReport.Load(reportPath)
            finalReport.SetDataSource(detailValues)

            'subreport 1
            finalReport.OpenSubreport("SubSummaryHeader.rpt").SetDataSource(summaryValues)
            CrystalReportViewer1.ReportSource = finalReport

            'subreport 2
            finalReport.OpenSubreport("SubAtAGlance.rpt").SetDataSource(ataglanceValues)
            CrystalReportViewer1.ReportSource = finalReport


I appreciate any pointers. Thank you.
0
brooksgroup
Asked:
brooksgroup
  • 2
  • 2
1 Solution
 
frodomanCommented:
When you set viewer.reportsource that does a databind on your control.  I think the problem may be that you're setting the reportsource twice.  Try commenting out the first one and see if that resolves the problem.

If that isn't it, can you elaborate on what happens - do you get an error message?  Is the wrong data displayed?
0
 
brooksgroupAuthor Commented:
Thank you for the response.

>>I think the problem may be that you're setting the reportsource twice.

You are right. I dont' think I need the code twice. However, when I commented out first one, and it still gives me the same error.

It gives me this page: The report you requested requires further information.

It seems that the correct datasource is not set for the second report, SubAtAGlance.rpt.

Both subreport works fine when I have only one subreport.
0
 
brooksgroupAuthor Commented:
Ok, I got it to work. Here is how I set the datasources for each subreport.

            Dim reportPath As String = Server.MapPath("Report/Main.rpt")
            finalReport.Load(reportPath)
            finalReport.SetDataSource(detailValues)

            'subreport 1
            finalReport.Subreports("SubSummaryHeader.rpt").SetDataSource(summaryValues)
            'subreport 2
            finalReport.Subreports("SubAtAGlance.rpt").SetDataSource(ataglanceValues)
           
            CrystalReportViewer1.ReportSource = finalReport
0
 
frodomanCommented:
No objections to PAQ / Refund.
0
 
GranModCommented:
PAQ-ing the question and refunding 500 points

Thanks frodoman

GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now