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

Total count from report and subreport 1

Status
Not open for further replies.
Apr 7, 2003
31
US
I am trying to create a report of current clients with a subreport of clients on a leave. The report and subreport are linked together and are working correctly, but how can I get a total of all of the clients?

I am doing a count on the ID, but I can not get the two totals to become a subtotal for the group and then a grand total for the report.

(I am very new at Crystal if you can't tell).
Thanks in advance for any suggestions!

Jim Johnson
IT Specialist
Wyoming State Hospital
 
You need something called a 'Shared Variable'. Do a keyword search, there's lots of existing good advice.

Madawc Williams
East Anglia
Great Britain
 
As Madawc pointed out you do this with "Shared" Variables.

The simplest method would be to declare a Shared variable called "SubTotal" in your Subreport report header

@initialize
WhilePrintingRecords;
//This will reset your subtotal when the subreport is run
shared numberVar Subtotal := 0;

Then when you display the subtotal value you assign it to this variable to be passed to the main report

@DisplaySUbTotal
WhilePrintingRecords;
shared numberVar Subtotal ;

..... other stuff for the formula if necessary...

Subtotal := (enter your summing expression here)

Subtotal;

In your main report In the report header Initialize a GrandTotal variable

@Initialize

whilePrintingRecords;
NumberVar GrandTotal := 0;


Then later...in a section after the subreport (NOT in the same section)...if necessary create an (A) and (B) section with the subreport in (A) and this formula in (B) have a calc formula like

@Calc
whilePrintingRecords;
NumberVar GrandTotal ;
shared NumberVar Subtotal;

GrandTotal := GrandTotal + Subtotal;

The later display the GrandTotal


@DisplayGrandTotal
whilePrintingRecords;
NumberVar GrandTotal ;

GrandTotal ;


That is it



Jim Broadbent
 
Ngolem

Thanks for the help!

I had to do a couple of other things to make it work, but it works great!

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top