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
janineoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ebolekCommented:
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
mlmccCommented:
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
janineoAuthor Commented:
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ebolekCommented:
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
janineoAuthor Commented:
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
mlmccCommented:
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
janineoAuthor Commented:
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
ebolekCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
janineoAuthor Commented:
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
ebolekCommented:
Reagrds
Emre
0
mlmccCommented:
Glad i could help

mlmcc
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.