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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a Value from Sub-Report to Main Reports Report Header? 1

Status
Not open for further replies.

akabatman2

Programmer
Feb 25, 2003
102
US
Hi All,

Is it possible to pass a value from a sub-reports dataset to
the main reports Report Header section?

I've seen pleanty of parameter pass threads that explain how to pass values between sub-report and main report, but
haven't seen one that addresses this issue.

Example:

Stored procedure for Subreport1 returns

TransID Detail
1 This is a Transaction

SubReport1 is in GroupHeader#1 section.

How do I use parameters or shared variables to grab the TransID from Subreport1 and be able to display it in the Main Report's Report Header section?

Is this possible?

Any help or insight would be much appreciated.

Thanks,

Tom
 
A subreport returns data after it has fired, so if you want the subreport to return a value to the Report Header, the subreport would have to be in a previous report header.

You can right click a section and select insert section below and place the subreport in the first section, and the display of the share3d variables in the second.

Since you're currently placing the subreport in a group, it is returning multiple values to the main report (assuming that the use of grouping makes sense, which means there is more than one). So which value do you intend to display in the Report Header? Is it a sum?

Try providing technical information, such as:

Crystal version
Database used
Example data
Expected Output

Shared variables are fairly simple, btu I think that you need to resolve some architectural issues before proceeding, and remember that subreports are slow and you might be able to let the database do all of the work depending upon the above.

-k
 
k,

Thanks for the response. Yes, ended up just having the transactionID return in the stored procedure called by the main report.

I was trying to determine if data from a sub-report could somehow be captured and then displayed in the main reports header. I understand the multi-pass architecture of Crystal. I just wanted to see if there was a way to grab data from a sub-report and display it on the main report in a section (Report Header) above the sub-report.

Crystal Version 9
SQL Server

Example data:

TransID Detail
1 This is a Transaction
2 This is another Transaction

Expected Output:

Report Header: "TransactionID: 1"

Group 1: Sub-Report that calls the proc that gathers the example data listed above.

My guess is that this is not possible, or it involves a combination of using WhileReadingRecords and WhilePrintingRecords.

Thanks again,

T

 
I guess you don't understand how Crystal works.

Think of it like SQL in this example:

select State, sum(amount)
from table
group by State

Each State would have a separate value, so what do you expect to be displayed in the report header? Your example output shows only the first row. Given that the report header only displays once at the beginning of the report, place the subreport prior in a report header section prior to the report header section displaying the results.

Aside from the basic logistical error, Crystal doesn't execute the subreport until AFTER the report Header if it's in a subsequent section.

Y
 
Y,

Your purely logical response is appreciated and I do understand Crystal Architecture. I am certified with it.

I understand when the sections are processed, etc.

I was simply asking if there is maybe a "jury rigged" way to pass a value between a sub-report and a report header.

I am guessing that the answer is no.

Thank you for taking the time to respond though,

T
 
i was shown how to do this and have done this.
i had a total passed into the main report so i could do a percentage at the detail level.
let me see if i can explain.
but just in case you don't understand you can contact me.
jill messier
8605296232
jillm@ccc24k.com

shared varable from sub report to main report:
create your report and do your totals etc. then create formulas that share (like below then save and bring into main report as a sub report)

WhilePrintingRecords;
Shared numbervar shsale:= Sum ({@SalesDlr})

then place your subreport into the report headerA and surpress.
insert a report headerB and create another shared formula variable. Like below
GRAND TOTAL FORMULA =
WhilePrintingRecords; Shared numbervar shsale;shsale

WhilePrinting Records semi colon then shared numbervar or char semi colon the variable name must be the same as in the subreport semi colon and the name again.

You can not SUPRRESS or HIDE these report headers you must format them. Go to format section and check off the last box for each header.
this box is labeled,"underlay following section" This hide the section behide another.
If you need to use the header page for the report then just make the font color white.
Now GrandTotal is useable for formulas to do a percentage and sorts and then do a count if you only want to show the top 20% records.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top