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

Can I insert the value from a subreport into a formula?

Status
Not open for further replies.

pokerace

Technical User
May 24, 2005
118
US
I have a report with one subreport. The subreport is calculating a value and I would like to enter that calculated value into a formula in the main report. Is there a way to insert the subreport's produced value?
 
Data can be passed between main and sub reports using shared variables.
In your case create a formula in your sub report that sets a shared variable to the value you want to pass to the main report:
// {MySharedVariable}
WhilePrintingRecords;
Shared StringVar MyShrVar;
MyShrVar:= (calculation or database field)

In the main report create a formula that declares the same shared variable, but do not assign a value. Place the formula in the main report in a section below the section containing the subreport:
// {MySharedVariable}
WhilePrintingRecords;
Shared StringVar MyShrVar;

Also, be sure to create a formula in the report header of the subreport that resets the shared variable back to zero or blank or null:
// {MySharedVariableReset}
WhilePrintingRecords;
Shared StringVar MyShrVar:= ""

The formula declaring the shared variable in the main report will contain the value set in the subreport and is available for display, calculations, etc.

MrBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top