Print Page | Close Window

Subreports Not displaying

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=43
Printed Date: 17 May 2024 at 8:44pm


Topic: Subreports Not displaying
Posted By: Mongoose
Subject: Subreports Not displaying
Date Posted: 07 Dec 2006 at 2:24pm
I have an ASP.NET 2003 application with 3 crystal reports.  Two of them are subreports that display inside the third.  If I try to run the application, it asks me to log on to the server, then displays a blank page.  If I remove the sub-reports and just set the ReportSource to either of the other two reports, it runs perfect without asking me to log in.  It knows the server, database and user, but wants the password.
 
Is there some trick to getting Subreports to display correctly?  I have not had much luck in finding an answer.
 
Here is a code snippet with what I am doing
 
==================================================

selectString = "SELECT ..."  ' not showing actual sql  to save space

Dim dsDaveTest1 As DataSet = New DataSet
Dim hpdata1 As SqlDataAdapter = New SqlDataAdapter(selectString, goConn)
hpdata1.Fill(dsDaveTest1, "MASTER1")
Dim cr1 As CrystalReport1
cr1 = New CrystalReport1
cr1.SetDataSource(dsDaveTest1)
 
selectString = "SELECT ..."  'not showing actual sql string to save space
Dim dsDaveTest2 As DataSet = New DataSet
Dim hpdata2 As SqlDataAdapter = New SqlDataAdapter(selectString, goConn)
hpdata2.Fill(dsDaveTest2, "MASTER2")
Dim cr2 As CrystalReport2
cr2 = New CrystalReport2
cr2.SetDataSource(dsDaveTest2)
 
Dim cr3 As CrystalReport3

cr3 = New CrystalReport3

CrystalReportViewer2.ReportSource = cr3
 
==================================================
 
Thanks in advance....
 
Mongoose



Replies:
Posted By: BrianBischof
Date Posted: 07 Dec 2006 at 3:29pm
I have more information about this in my book, but here is the basic way things work. The subreport is part of the main report. So you can't treat the subreport seperately from the main report. Instead, you have to access the subreport object via the main report. Here is some sample code, but you have to fill in the part that actually open the datasource (as you already have listed above). Also, I'm making up the report names, so you have to replace this with your own names.

cr1.SetDataSource(dsDaveTest1)
cr1.OpenSubreport("subreport1").SetDataSource(ds1)
cr1.OpenSubreport("subreport2").SetDataSource(ds2)




Posted By: MacksDaddy
Date Posted: 31 Oct 2007 at 7:56am
Brian,
Is there a way to generate the subreport dataset each time the subreport is activated using one of the fields of the main report?
Thanks.


Posted By: Savan
Date Posted: 17 Dec 2007 at 1:58am
Yes, its possible to activate subreport by using one of the fields using main report. You have to create a link to subreport based on the filed in the main report.  Right click on the subreport and u will get a option
"Change subreport links". By using this option u can create  link between the main report and sub report. I hope i was able to slove ur problem
 
 


-------------
Thanks
Savan


Posted By: Roopangee
Date Posted: 31 Oct 2008 at 6:20am
Thanks a lot Brain f for the information..It has helped me create a subrepot!
Thanks again


-------------
Roopangee Tandon



Print Page | Close Window