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

Shared Variable with Subreport in Details

Status
Not open for further replies.

hebuna

Technical User
Feb 14, 2006
8
US
I've searched this a few times but it seems to be clear as mud to me. Using Crystal XI and SQL Server.

The report I'm working on is of all active customer equipment and the leases and contracts that are active for each respective machine. My main report and subeport are grouped by customer zip code. My subrport is in the details section of the main report.

In the subreport there is a points system for each machine -
{@LeaseCount} //count of active leases
{@EquipContractCount} //count of active service contracts
{@HPCount) //count of HP contracts
{@ITCount) //count of IT contracts

{@Sum} = {@EquipContractCount}+{@HPCount}+{@IT Count}+{@LeaseCount}

Here's what I need to accomplish -
I need a total of the {@sum} (which I currently have in the subreport as a running total {#Total Points}) placed in the main report totaling & resetting on each group level. I know that I need to do this as a shared variable which is where I get stuck. I have the variable written in the subreport as:

WhilePrintingRecords;
Shared numberVar TotalPoints := {#Total Points}

and in the main report as

WhilePrintingRecords;
Shared numberVar Total Points;
Total Points

But I have no idea if they are correct and then where to put them in the report. I know that you may need more data information to help me but I didn't want to include too much! I appreciate any help on this!
 
So does your main report look like this?

GH1 - zip code 02453
details - machine1 sub showing points
machine2 sub showing points
machine3 sub showing points
GF1 - show total points for zip code 02453
GH1 - 02454
//etc.

Also, I am confused by your showing all the formulas for summaries, and then referencing a running total. Which is it? If you are using a running total in the subreport, exactly how is it set up? Why is the sub in the details section? Is it linked by machine and zip code?

Note also that you should always show the actual contents for formulas you reference in a thread.

-LB
 
Ok - here goes ...

My main report looks like this.
GH1 - {SCEquipments.Zip} (This is suppressed)
GH2 - {ARCustomers.CustomerName} (Also suppressed)
Details -
Abc Company Machine/Lease Information:
123 Main St. MIN 3050 EQ1234
Town, ST 00000 Wells Fargo 1/1/2000 1/1/2010
John Smith
(111) 111-1111 Contract Information:
jsmith@abc.com C00000123-03 Gold Lease = 1
Machine Location: 1/1/2007 1/1/2008 MA = 1
345 Main Street HP = 0
Town, ST 00000 IT = 0
= 2
GF1-Need to show average point total per machine for {SCEquipments.Zip} (I figured if I could get the total to report right then I could create a formula of Total Points/Count of Customers)

The subreport is everything under the Contract Information Heading. It also has a GH1 of {SCEquipments.Zip} which is suppressed. It is in details for formatting purposes. Because of the selections that I need for contracts, I could not get it to report properly without being a subreport.

My sematics were wrong - the formulas are not summaries. That was just my own way of referencing them. Here are the formulas -

{@LeaseCount) = if {LeaseCo}="Purchase" then 0 else
if {SCBillCodes.BillCode}="IT" then 0 else 1

{@EquipmentContractCount} = if {SCContracts.Active}= true and {ICMakes.Make} <> "HP" and {SCBillCodes.BillCode} = "silver" then 1 else if {SCContracts.Active}= true and {ICMakes.Make} <> "HP" and {SCBillCodes.BillCode} = "gold" then 1 else if {SCContracts.Active}= true and {ICMakes.Make} <> "HP" and {SCBillCodes.BillCode} = "platinum" then 1 else 0

{@HPCount} = if {SCContracts.Active}= true and ({ICMakes.Make}= "HP" OR {ICMakes.Make}="LEX" OR {ICMakes.Make}="XEROX") and {SCBillCodes.BillCode} = "bronze" then 1 else if {SCContracts.Active}= true and ({ICMakes.Make}= "HP" OR {ICMakes.Make}="LEX" OR {ICMakes.Make}="XEROX") and {SCBillCodes.BillCode} = "silver" then 1 else 0

{ITCount} = if {SCContracts.Active}= true and {SCBillCodes.BillCode} = "it" then 1 else
if {SCContracts.Active}= true and {SCBillCodes.BillCode} = "itblock" then 1 else 0

{@Sum} = {@EquipContractCount}+{@HPCount}+{@IT Count}+{@LeaseCount}

I then created a Running Total {#Total Point) which is Sum{@Sum}.

I have the two reports linked by the equipment number only.

Sorry - I know it's a lot but I appreciate your help!
 
Is there only one machine per client with a machine number that is unique to that machine/client? If so, then you should be able to set up a formula like this:

whileprintingrecords;
shared numbervar totalpoints := sum({@sum});//or use the rt

Place this in the report footer of the subreport.

Then insert two detail sections. Place the sub in the detail_b section, and place the following formula in detail_c:

whileprintingrecords;
shared numbervar totalpoints;
numbervar sumpts := sumpts + totalpoints;
numbervar cnt := cnt + 1;

In GH1 place this formula:

whileprintingrecords;
numbervar sumpts;
numbervar cnt;
if not inrepeatedgroupheader then(
sumpts := 0;
cnt := 0
);

In detail_a, place the following:
whileprintingrecords;
shared numbervar totalpoints := 0;

Then in GF1 place this formula:
whileprintingrecords;
numbervar sumpts;
numbervar cnt;
if cnt <> 0 then
sumpts/cnt

-LB
 
lbass -

You are absolutely my 100% hero! That worked like a charm. If you are ever in Denver, I owe you a drink!

Thank you so much! [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top