Solved

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

Posted on 2014-11-05
5
211 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

27 Experts available now in Live!

Get 1:1 Help Now