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

Using Subreport Field in Main Report

Status
Not open for further replies.

Hillary

Programmer
Feb 15, 2002
377
US
Can a field in a subreport be used in a formula in the main report? The table the field is on is only in the subreport, not in the main report.

Thanks,
Hillary
 
Hillary

You can not use the actual field, but you can capture its value using a shared variable.

This variable can then be used inside a formula in the main report.

Ian
 
Can you help me with creating a shared variable? I have never done a variable before.

In the main report I have Work Order and Quantity fields. The subreports are linked via the Work Order field. One subreport has the Material Cost. The other subreport has the Labor Cost, Burder Cost and Service Cost fields. I want to get the Unit Cost of a Work Order. The formula will be (Material Cost + Labor Cost + Burden Cost + Service Cost)/Quantity

Thanks for your help!

Hillary
 
Create formula in sub report and insert in detail line or group line if calculated from a summary.
@material cost

whileprintingrecords;

// This ensures it is reset to 0 every time you use it.
shared numbervar material:=0;

// This calculates variable value
material:= {Feldname or formula};

In your main report amend your formula which calculates total cost.

whileprintingrecords;
shared numbervar material;

(material+ Labor Cost + Burden Cost + Service Cost)/Quantity


Hope this is clear good luck.

Ian Waterman
UK Crystal Consultant


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top