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

Referencing Subreport 1

Status
Not open for further replies.

Jefftopia

Programmer
Jul 30, 2002
104
US
Here is my situation.

I have a main report containing one sub report. In the sub report I have a beginning account balance. In my main report I have account activity and a running sum of that activity.

What I need to do now is have a formula which takes the beginning account balance from my sub report and in the main report adjusts the account balance by the running sum of the account activity (i.e. calculate the adjusted balance resulting from acct activity).

The problem I am having is in trying to build a formula in my main report which will reference the sub report to get my beginning account balance.

Is there a way to reference the sub report from the main report? Also note the reports are not linked.
 
use a shared variable to retrieve the beginning account balance.

In the group header for the account (in a subsection before the subreport if the subreport is located in the Group header) place this formula

//@InitBalance (suppressed)

WhilePrintingRecords;
Shared numberVar Balance := 0;

In the subreport footer place this formula in a suitable location (subreport footer??)

//@OpenBal

WhilePrintingRecords;
Shared numberVar Balance := {Table.OpeningBalance};

Now later in the main report detail section place this formula

//@CalcBal

WhilePrintingRecords;
Shared numberVar Balance ;

Balance := Balance + {Table.AccountActivity};

(or Balance := Balance - {Table.AccountActivity};
if the {Table.AccountActivity} is +ve and you want it subtracted)

//@DisplayfinalBalance (placed in a the grup footer)

WhilePrintingRecords;
Shared numberVar Balance ;

Balance ;





Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Ngolem, excellent.

Works great.

Appreciate your response:)
 
Follow-up question:

How could I change @CalcBal to add the last single account activity instead of the sum of all prior account activity?

Gracias
 
To be specific, I am trying to build a formula to be used to determine "Availability". Ngolem provided a good technique for calculating "Total Assets", but I am having difficulty in altering that formula to determine "Availability".

Here is what I am looking for:

Activity Total Assets Availability
600.00 40.00
7.00 607.00 32.00
5.00 612.00 27.00
1.00 613.00 26.00
 
On the first line, why would availability drop 8 when the activity is only 7?

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Because I can't add. Here it is again.

Activity Total Assets Availability
600.00 40.00
7.00 607.00 33.00
5.00 612.00 28.00
1.00 613.00 27.00
 
As always PLEASE STATE HOW YOUR REPORT IS GROUPED...still working on guesses here

Add another group to the report...ASSUMING the report now is

Group 1 header (Account)
Details
Group 1 footer

Make it

Group 1 header (account)
Group 2 header (account activity)
Details
Group 2 footer (suppressed)
Group 1 footer

change the formulas slightly
NOTE: I have changed the variable names to suit new information

//@InitBalance (suppressed in Group 1)

WhilePrintingRecords;
Shared numberVar TAssets := 0;
Shared numberVar Available := 0;

In the subreport footer place this formula in a suitable location (subreport footer??) NOTE: Suppress all lines of the subreport so it is invisible...also suppress its borders.

//@OpenBal

WhilePrintingRecords;
Shared numberVar TAssets := {Table.TotalAssets };
Shared numberVar Available := {Table.Available };

Place the above subreport Suppressed in Group 2 header Subsection A (make the subsection very thin as well as the subreport)

In Subsection B of Group 2 header place the following formula

Create the headings Of Activity, Total Assets and Available

then place the following formulas under the appropriate heading

//@DisplayOpeningTAssets

WhilePrintingRecords;
Shared numberVar TAssets ;
TAssets ;

//@DisplayOpeningTAssets

WhilePrintingRecords;
Shared numberVar Available ;
Available ;

Now in the detail section of the main report which is now displayed place the following formulas under the appropriate heading (along with activity)

//@CalcRunningAssets

WhilePrintingRecords;
Shared numberVar TAssets ;

TAssets := TAssets - {Table.AccountActivity};


//@CalcRunningAvailable

WhilePrintingRecords;
Shared numberVar Available ;

Available := Available - {Table.AccountActivity};

No need for a footer formula now


That should work for you.....

NOTE: You have done something that I really dislike from my clients.....you changed the nature of the problem after I supplied a solution. I'm sure you would be ticked if your user kept on "changing the report slightly". As you can see these slight changes often require a complete re-think of the report.

Present the complete problem...not a snippet.





Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top