?
Solved

Using Main report datasource in sub reports

Posted on 2004-11-03
11
Medium Priority
?
612 Views
Last Modified: 2008-02-01
Hi,

I have a report which I populate from an ado.net dataset through VB.NET.
However this report has 31 sub reports and it takes a long time to set the datasource for each of these programatically.
However, the dataset is the same for all the subreports and the main report and I was hoping there was a way to just set the datasource in the main report and have it filter through to the sub reports.
I've tried linking the fields in the sub report to identical ones in the main report, but this doesn't work.

Can anyone tell me if this is even possible?

Thanks,
Janine
0
Comment
Question by:janineo
  • 4
  • 4
  • 3
11 Comments
 
LVL 10

Expert Comment

by:ebolek
ID: 12483057
Thus sub reports have datasets as their datasource. If you use datasets as the subreport's datasource, you have to fill those datasets first too. If not, you can link the main report to subreport and it will work
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12483363
The link is used to filter the subreport and report on only the related data not to fill the subreport fields with information.

I believe since you are using datasets you will have to assign the datasets as you are doing.

Why does the report require 31 subreports?

mlmcc
0
 

Author Comment

by:janineo
ID: 12483459
Maybe I should explain it a bit more.

I have a report with 31 sub reports in it.
The data for this report is an XML file which I read into a dataset in VB.NET

I use this to set the datasources:

[code]
Dim objReport As CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim objXMLDataDoc As New XmlDataDocument

objReport = New rptEntireCase

' objFixedUpData is an XMLDocument containing all the data I need        
objXMLDataDoc.LoadXml(objFixedUpData.InnerXml)
objReport.SetDataSource(objXMLDataDoc.DataSet)

' Then set the sub report datasources
For Each objSubReport In objReport.Subreports
     objSubReport.SetDataSource(objXMLDataDoc.DataSet)
Next

[/code]

The setting of the datasources for the subreports takes a long time - several minutes.
What I would like to do is to just set the datasource for the main report and have the sub reports pick up their data from the main report datasource.

However I have tried linking the fields in the subreports with the fields in the main report and just setting the main report datasource and no data is displayed in the subreports.

Please help
Janine

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:ebolek
ID: 12483628
seems like because you created the sub reports also with datasets you have to fill them up programaticallly. Sub reports are not good for performances and datasets make it worse. But if you can tchnage the datasource to pull method for subreports you have to do what you are doing

Regards
Emre
0
 

Author Comment

by:janineo
ID: 12483833
ebolek - can you explain what you mean by ' because you created the sub reports also with datasets you have to fill them up programaticallly ' please. How else could I create the sub reports? what other datasource could I use?

mlmcc - I could probably cut down the number of sub reports a bit, but it mostly requires that many because of the data it is displaying - there are lots of distinct tables of data, each needing their own details and header sections, and there are also several places that display an address - which are stored in their own table and therefore need to be in a linked subreport to display the correct one.

I'm sure some of this could be done better if there was a proper database behind it, but it is all based on a single XML document.
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 1000 total points
ID: 12489319
I am not that familiar with the XML methods with Crystal.

As emre pointed out subreports are inherently slow and Crystal recommends avoiding them if possible.  I suspect in your case it is not possible because of the nature of your data and its source.

You created your reports against a dataset rather than a database source.  With your XML file it was probably the only option.  Since they were created aagainst a source that doesn't really exist on its own you must fill the report programatically as you  are doing.

It is possible that a better solution would be to create a database and populate it before runnning the report.  This would be a large investment in time on your part but might reduce report generation and maintenance enough to make it worthwhile.

mlmcc
0
 

Author Comment

by:janineo
ID: 12491293
mlmcc
Well, it's nice to know I'm probably doing it the only possible way.
Creating a database probably wouldn't be practical as this report will be running on tablet PCs on site - they wouldn't have the processing capability for it, let alone the software!

I'm thinking I might be able to create smaller datasets from the large one for each subreport as each one generally uses only a few 'tables' of the large dataset. That might speed it up a bit.
0
 
LVL 10

Accepted Solution

by:
ebolek earned 1000 total points
ID: 12493463
There are two methods to retrive the data

1. Push: In this method, you use datasets as your datasource. You fill the datasets with data first then you set it t othe report
2. Pull: You use tables, views, stored procedures, sql command as your datasource. There is no filling involved. You directly call the report

I have done reports that include sub reports. Main reports datasource uses method1, and all the subreprots use method2.

Regards
Emre
0
 

Author Comment

by:janineo
ID: 12494429
Emre,

Thanks for the explanation, it makes sense now!
As my data is in an XML file I will have to go for the Push method.

I am splitting the points between you both as you both helped me answer my question - no it's not possible, and I am stuck with my current method.

Thanks,
Janine
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12494486
Reagrds
Emre
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12500533
Glad i could help

mlmcc
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question