Link to home
Start Free TrialLog in
Avatar of janineo
janineoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using Main report datasource in sub reports

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
Avatar of ebolek
ebolek

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
Avatar of Mike McCracken
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
Avatar of janineo

ASKER

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

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
Avatar of janineo

ASKER

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.
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janineo

ASKER

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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janineo

ASKER

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
Reagrds
Emre
Glad i could help

mlmcc