知識庫

REPORTS: 2.To pass a value from a SubReport back to the Main Report

Hint Ref: 020602271324
Hint Date: 27/02/2006

Hint Details:

1. On the main report, select the 'Report' menu, 'Pass Setting' and set it to 'One pass'. 

2. On the main report, select the 'Calc' tab and change to the 'Module' view by right clicking in the top left window and selecting it from the list.

3. Select 'Declarations' then right-click on 'Variables' and select 'new'

4. Add a new variable such as

        MyVariable : double;

5. Select the SubReport and return the 'Calc' tab to showing 'Events' by right clicking in the top left window and selecting it from the list.

6. Locate the item you want to pass back (say DBCalc1) and create an 'OnPrint' procedure

      MyVariable : = DBCalc1.Value;

7. Place a Variable on the main report (say Variable1)

8. Select the 'Calc' tab and then 'Variable1' in the top left hand window. Create a procedure for 'OnCalc'

    Variable1.Value := MyVariable;

9. Go to the Design Tab and right click on Variable1, select 'Timing....'

10. If the page separation is determined by a Group;

for 'Calculate On' choose 'Group End' and select the grouping from the drop-down list.

for 'Reset On' choose 'Group Start' and select the same grouping from the drop-down list