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!

Problem with running total formula

Status
Not open for further replies.

rbdan

Programmer
Jul 13, 2012
2
US
Need to have a running total on Quantity by Order No Group.
1 - Item No, 2 - Dept No, 3 - Order No, Quantity

Here's Reset code: Placed in the Group Header for Item No
Whileprintingrecords;
Numbervar Amount := 0

Here's Qty code:
Whileprintingrecords;
If onfirstrecord or previous({SHOP_ORD_EFF.ORDER_NO})<>{SHOP_ORD_EFF.ORDER_NO} then
Numbervar Amount:= Amount + 1;

Here's Display code: Placed in the Group Footer
Whileprintingrecords;
Numbervar Amount;

It all works fine if I only have the two groups Item No and Order No, when I try to add another group Dept No the calculation is off.

The data I am working with for example:

Item No:; Dept No:; Order No:; Quantity:;
1234; 02; 10001; 0;
1234; 03; 10001; 0;
1234; 04; 10001; 0;
1234; 05; 10001; 10;
1234; 06; 10001; 0;
1234; 07; 10001; 10;
1234; 08; 10001; 0;
Total for Group Order No: 10

1234; 02; 10002; 0;
1234; 03; 10002; 0;
1234; 04; 10002; 0;
1234; 05; 10002; 1;
1234; 06; 10002; 0;
1234; 07; 10002; 1;
1234; 08; 10002; 0;
Total for Group Order No: 1
Total for Group Item No: 11

1235; 02; 10002; 0;
1235; 02-1; 10002; 19;
1235; 04; 10002; 0;
1235; 05; 10002; 19;
1235; 05-1; 10002; 0;
1235; 07; 10002; 0;
1235; 08; 10002; 19;
1235; 15; 10002; 0;
Total for Group Order No: 19
Total for Group Item No: 19

1236; 02; 10003; 1;
1236; 02-1; 10003; 0;
1236; 04; 10003; 1;
1236; 05; 10003; 1;
1236; 08; 10003; 1;
1236; 09; 10003; 1;
Total for Group Order No: 1
Total for Group Item No: 1

Don’t need total by dept no but need over all total by item no.

The quantity on the order is only 1 but can be worked in multiple departments but only want to show 1 not 3 or however many dept no’s there are. Once I add the department it counts it for each department.

Hope you can understand where I am trying to go.
Thanks in advance for the help,
Rbdan
 
I'd suggest a completely different method. Use Crystal's automatic totals rather than your own variables, which are not needed in most cases.

The use of Crystal's automated totals is outlined at FAQ767-6524. Do a few test reports to get familiar with how they work: you will then be able to code much faster.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Madawc,

Thank you for the help, we finally got it running.

Rbdan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top