Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats the best way to the result from another report into a report? 1

Status
Not open for further replies.

ekimr

Technical User
Jun 28, 2002
124
GB
Hi,

I have a report that works, it isn't a rocket science report, but being a novice, it was a bit tricky. However I need the result from that report (from a summary field) into my main report.

2 purposes of my main report.

either

a: print and distribute, so therefore need to capture the 'result' from the other report

or

b: in demo - maybe I just want to call the other report by clicking on the 'field' that would hold the result..

Hope that makes sense, and any help would be greatly appreciated.
 
Insert the report that you want the result from in to the main report as a subreport (use Insert->Subreport).

One option will be to select on-demand report, which means that you'd have to click the report for it to display data.

If you don't want to directly display the data from the subreport, rather use a value within the main report, then
use a shared variable in a formula within the subreport, as in:

whileprintingrecords;
shared numbervar SubNumber := sum({table.field});

Now you can reference this value within the main report anytime AFTER the subreport executes using a formula such as:

whileprintingrecords;
shared numbervar SubNumber;
SubNumber

I hope that this describes the options well enough.

-k
 
Hi

Thanks - I am sure it makes sense...I just can't see it at the mo!!!

I have trailer field in my main report - lets say it holds text called 'number of machines' and needs to display a numfield called No_of_machines.

This value can be got from another report - that I don't want the user to know has been called (but it does behind the scenes!).

What would I put in the formula field of No_of_machines in my main report to execute the sub report 'invisibly' and return the value I want? or is this too simplistic in my very limited understanding.

I guess I am not seeing where your various syntax (below) would actually be placed. Many apologies and thanks for your time anyway.

"whileprintingrecords;
shared numbervar SubNumber := sum({table.field});"

and

"whileprintingrecords;
shared numbervar SubNumber;
SubNumber"

 
Where you fire the subreport is dependent upon where you need the value in the main report.

As for making the subreport invisible, you can't, but you can suppress every section in the subreport, and reduce it to being very small and turn off the can grow and borders, and even overlay it with other text or whatever.

If you need just one value from the subreport, place the subreport in a separate Report header (right click the report header and select insert section below).

Create the formula containing:

whileprintingrecords;
shared numbervar SubNumber := sum({table.field});

in the subreport to get the value you need.

Now create the main report formula:

whileprintingrecords;
shared numbervar SubNumber;
SubNumber

And anywhere after the report header B subreport section this formula will have the subreport value in it.

-k
 
This is a very handy set of commands. For the first time, using a shared total from a sub-report, I was able to emulate a pre-processed total in Crystal. I used Report Writer before I started using Crystal and I've missed this option dearly ever since.

But I have another problem =)
To finish the report I've been wanting to design, I would also like to know how I can share a query field.

Currently I have two parameter fields (From Date and To Date)in the main report and the same parameter fields in the sub-report. The parameter fields in each case represent a range of dates that I want the report to look for. While that setup will run the report I need, it's sloppy. I have to enter the same date range for each set of parameter fields. Another report I need this strategy for will require quite a few sub-reports for every instance of a pre-processed total and, for every instance, another two parameter fields that must have the same two dates entered over and over again every time I run the report (I think I'm looking at up to 20 pre-processed totals, for a grand total of 40 parameter fields, entering the same 2 dates 20 times each, for every time I run the report. Bleh =)

I attempted to use the above to share the parameter fields across reports, but as I suspected I got the "The formula cannot be used because it must be evaluated later" error.

Any ideas? =)

Thanks in advance.
 
Nevermind guys, I got it.
You can use subreport links to link parameter fields between the main report and any number of sub-reports.

Me so happy =)
 
Smaug,

If you are comparing to R&R Report Writer, then ALL of the normal totals in CR are like R&R 'preprocessed' totals. This means that they are available for formulas at the beginning of the report or group, and can be used for selecting (group selection) and Sorting Groups (TopN). But preprocessed totals only work within a single report. Shared variables allow you to swap values from one report to another.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Kenhamady,

Now that this thread is off on a tangent, I'd like to take a quick detour...

You are able to emulate pre-processed totals in any way that Report Writer does while using Crystal? *gasp*

We've been told by our 'expert' software vendors who support Crystal for our SQL Database that it is not possible. Anytime we need to apply logic to a total, we have not been able to figure out a way to pre-process that result without going to subreports. The summary function only seems to work if you are willing to include every record that has been selected. Our reports are rarely ever simple enough to just accept a total for all selected records.

I would love to know how to pre-process a conditional total...

:)
 
They have some differences but I believe that CR allows you to do all of the same things. Here is how I see it:

Default totals in R&R are running totals. If you put them in the Group header you see zero. Placed on the details band they accumulate line by line. If you want to see accurate totals in the GH, then you set them to be preprocessed. Then they are available in the GH, details or the GF.

All of CR's totals are PreProcessed by default. You can put them in the GH or GF and get the same result. You can use a formula to put them on the details band and you see the value repeat. You have to use a separate object to get a running total.

Give me an example of a pre-processed conditional total that you can do in RR and that you can't do in CR without using subreports?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
"All of CR's totals are PreProcessed by default."

The problem isn't that CR's totals aren't pre-processed, it's that CR does is not readily capable of pre-processing totals with logic, whereas Report Writer can. Sum({table.billed},{table.datepaid}) works just fine and pre-processes the amount for use on any detail line you like, but what if you only want to sum that amount for specific records in the report?

"Give me an example of a pre-processed conditional total that you can do in RR and that you can't do in CR without using subreports?"

Imagine a table that includes claim#, net amount, date paid, PHCODE (either P or H), and HPCODE (various codes can be identified as either Senior or Commercial health plans). Group the table on the month paid.

The report has 4 totals summing the net amount on each group line, one for each combination (P and Senior, H and Commercial, P and Commercial, H and Senior), and 4 grand totals that sum up the associated group totals.

Now, say you want to know what percentage of each total was paid per month.

I hope that all makes sense =P

In Report Writer, you just open the grand totals' properties and tell it to pre-process and then you can use that full total on detail lines any way you see fit.

In Crystal, I've found no way to pre-process logical totals without sub-reports. If you've got one, I'd sure love to hear it =) The sub-report thing works but it sure is a lot harder to do then clicking a "pre-process" radio button =)
 
Another example would be if you wanted to know how many referals there were for a given provider panel (panel= number of patients) We need that to calculate the expected auths per thousand members per year.

so I start by counting commercial and senior authorizations by PCP(Dr.) (two seperate totals) and then I need to put thoses totals in a calculation that includes a predefined array with the commercial and senior average enrollment. I create the arrays with case statements.

It's nice to just preprocess all of those totals and then use those in my ptmpy calculation.

TotComRefrls_Dr1/((Totalcom_panelDr1*1000)/(Total_Refmonths/12))
 
Actually, this is pretty easy in CR.

Write a formula field that is:

If {PHCODE} = "P"
then {Amount}
else 0

Now add a grand total or subtotal of this field. You have a conditional preprocessed total - unless I don't understand you clearly.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Wow. Thank you. You just answered a question we asked our vendor over a year ago. They told us it just couldn't be done. (The vendor is obviously not 'Crystal') I will spread the word to quite a few relieved report designers over here now and they will all be thinking warm, fuzzy thoughts about you for a long time to come.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top