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

Passing variable from sub report to main.

Status
Not open for further replies.

sjjustina

IS-IT--Management
Apr 23, 2007
30
US
WhilePrintingRecords;
Shared numberVar TotalMAC;
TotalMAC := {far_item.pricequantity}

formula name is TotalMACSub

This is the main report
WhilePrintingRecords;
Shared numberVar TotalMAC;
TotalMAC;

formula name is TotalMACMain. The subreport prints data and the subtotal fine, it is not an on-demand subreport. It just prints Zeros instead of the subtotal.

Thanks in advance, Sarah
 
Sounds like you're new to shared variables.

Here'san overviewas yourposting didn'tsupply the location of the subreport in the main report, nor where your formulas are, which is critical to passing shared variables.

A typical use:

Main report group footer 1 is to display a value from the subreport.

Group header 1 would need a reset of the shared variable:

WhilePrintingRecords;
Shared numberVar TotalMAC;
TotalMAC := 0

Right click the groupfooter 1 and select insert section below.

Place the subreport in group footer 1A with the following formula within it:

WhilePrintingRecords;
Shared numberVar TotalMAC;
TotalMAC := {far_item.pricequantity}

Now in the group footer 1B you can reference the variable using:

This is the main report
WhilePrintingRecords;
Shared numberVar TotalMAC;
TotalMAC;

So, the thing to know is that you must reset variables if they're to be reused by the report, and that the variable is set WHILE it's section is executed. Once set, subsequent sections can reference that shared variable.

-k

 
Sorry, yes I'm very new to Crystal period.

The subreport is in a report footer and where I want the shared variable to print is a further down report footer.

So initializing that variable, where should I put it?

Thanks for your help. Sarah
 
Right click the report footer and select insert section below.

Place the subreport in report footer A, and the display formula in report footer B.

No reset of the variable is required because a report footer occurs at the end of the main report, so the shared variable is only used once.

-k
 
On a similar note,

How would you initialize multiple variables in one formula. So far, I've only been been able to reset one value to zero in each formula.

I'm using CR XI R1.

Thanks,

Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top