Solved

Can a subreport be done from data in the main report?

Posted on 2014-11-05
5
209 Views
Last Modified: 2015-02-12
I am working on a report that was written by someone else. This stored procedure for the report puts a pretty heavy load on the server, which I am going to rewrite, but is also puts all the data for the report in one record with many many columns. Because the data really does need to be output this way it is all printing at detail so when there is a break in a section of the detail the headings for that section do not reprint, there is no grouping or any way to create grouping since it is just one row.

My thought is to create subreports for all the different sections but I do not want to go back out to the database and have it run a new stored procedure for the subreports, I would just like to be able to use the data that gets created when the report is requested. Is there anyway to do this?

Thanks in advance for any and all input.
0
Comment
Question by:Peggy Bakos
5 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 168 total points
ID: 40423998
Yes it can but not easily.

You could use a shared variable for each column in the record and a formula that sets them in the main report.  You then create a subreport which uses the shared variables.

Basic idea
In the main report header add a formula
WhilePrintingRecords;
Shared StringVar PersonName = {PersonNameField};
Shared NumberVar PersonAge = {PersonAgeField};
etc
''

Open in new window


In the subreport create a formula for each field you need to display
WhilePrintingRecords;
Shared StringVar PersonName;
PersonName

Open in new window


mlmcc
0
 
LVL 18

Assisted Solution

by:vasto
vasto earned 166 total points
ID: 40424019
Crystal reports supports 2 ways to get data: PUSH and PULL. Most of the times you will use PULL method , which is to provide the connection information and ask the report to get the data. PUSH method is used in cases like yours , when there are too many subreports and you want to reduce the calls to the database or there is summary data calculated in the subreport , which should be printed before the subreport and shared variable will not work. If you are writing your own application you need to retrieve the data in a dataset and use SetDataSource method to pass it to the report.  You can prepare  the dataset by calling one stored procedure (or command) one time and generating multiple select statements , which will return multiple tables. The number of returned tables should be the number of subreports +1. Let's say you have one subreport,  you need to prepare a dataset with 2 tables , the first table will be set as a datasource for the report and the second one as a datasource for the subreport. If you have 5 subreports you need to return 6 tables.

If you are not writing your own application you need to use viewer , which supports external datasources. I know one , which supports this feature. You can check it her:  http://www.r-tag.com/Pages/default.aspx.
The external datasource is explained in this document : http://www.r-tag.com/Documents/RTag%20DataSource.pdf
There is a free version of the tool ( no tech support though), which supports this feature and is available from this page: http://www.r-tag.com/Pages/CommunityEdition.aspx
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 166 total points
ID: 40425828
Depending on how much data you're passing to the subreport, parameters might be easier than using shared variables.  Using a single parameter would be simpler than using a shared variable, but if you have to pass too many different fields, trying to use parameters could get messy.

 If you could give us some more information about the data and how it's used in the report, we might be able to offer an alternative approach.

 James
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now