It is possible to store data in a variable in a sub report and then fetch that same variable data in the main report. covered variables and variable • scope, but here I want to specifically discuss the use of variables to pass data between main and sub reports.
To store a variable in a sub report, write a formula declaring the variable andsetting its value. Be sure to declare the variable’s scope as Shared, indicating that this variable can and will be shared between the sub report and the main report.
As an example, I am using the report which is a Customer Listing main report with a Supplier Listing sub report. You want to count the total number of contacts, from both customers 2nd suppliers, for each region, To do this, you need the count of suppliers from the sub report to add to the count of customers in the main report. It takes a few steps to store the variable in the sub report and then fetch it in the main report, but the steps involve just two formulas,
The sub report contains the formula that declares the variable. Open the sub report s Design tab and click Insert, formula Field. Here, you need a formula to count the number of suppliers (for each region) and assign that number to a shared variable. The formula, which I’ve tided “Store,” This formula declares the scope as shared. The variable type is NumberVar and the variable name is GT. GT is equal to the count of the company names.