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

Make running total formula value available in sub-report 1

Status
Not open for further replies.

jollyreaper

Technical User
Jul 25, 2005
105
US
Crystal XI

I have a running totals formula that I would like to make available globally so it can be used in a sub-report. I will be using that running total value in a comparison in the sub-report to see if it is equal or not to another value in said sub-report. Do I have to create a function in the main report to specifically asign it as a global variable or is there a smarter way of doing it?
 
Global variables cannot pass to a subreport. What you need to use is a shared variable. In the section where you have placed the running total, place the following formula:

whileprintingrecords;
shared numbervar myrt := {#myrunningtotal};

Then in the subreport, you can reference the variable by creating a formula like:

whileprintingrecords;
shared numbervar myrt;
if myrt >= {table.myothervalue} then //etc.

The subreport must be placed in a section below the one in which the shared variable is declared in the main report.

-LB
 
Ok, I almost have it working. I think I'm mixing formats here between Crystal and Basic.

Here's the way the report is divided:

Group 1 header
details (all the good stuff here)
Group 1 footer (sums group 1, has first variance check, inserted your global var here as well, also call the sub-report here. The sub-report comes from an entirely different database and the report consists of showing the info by group from the first database and then showing corresponding data by group from the second database.)

This is my first check and it works fine.

If {#SalesTotal} <> {CCLIENT.DEPOSITREQD} Then
formula = "ERROR!!!"
End If

I put this function in the group 1 footer. No errors given.

whileprintingrecords;
shared numbervar myrt;
If myrt <> {#AccountingTotal} Then
formula := "ERROR!!!"
End if;


Now I tried putting this in the sub-report and it just complains.

whileprintingrecords;
shared numbervar myrt;
if myrt <> {#AccountingTotal} then formula="ERROR!!!"
end if

It says "A number, currency amount, boolean, date, time, date-time, or string is expected here." I'm mixing the syntax, aren't I?
 
Using CR syntax, try:

whileprintingrecords;
shared numbervar myrt;
if myrt <> {#AccountingTotal} then "ERROR!!!"

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top