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!

Dividing subtotal based on status

Status
Not open for further replies.

DeafBug

Programmer
Jul 31, 2003
47
US
I have a Purchase Order report to work on. The client called and demanded that we provide a subtotal based on status so Product Management gave in. Gee, now I am not sure how it works. I know I am on the right track but I can't get moving. The result is a SQL Query, a single recordset. There are two fields that I am trying to work on. There is a field called POStatus, it always will have a char of O,C,P, or V for Open, Closed, Paid, or Void. There is another field that I used for Grand Total called LineItemTotal. It is the sum of the indiviual PO transaction. The report already has two groups based on PONumber and Salesperson and I can't change it. So that is what makes it difficult.

I tried to use Running Total with using a formula but it doesn't work or I am not clear on that.

Basically all I am trying to do is create 4 sub totals based on the POStatus using the LineItemTotal. I would need 4 individual fields to display in the report footer.

I tried to use a formula like this but no luck.
CurrencyVar OpenTotal;
If {POTrans.POStatus} = "O" Then
OpenTotal := OpenTotal + POTrans.LineItemTotal

In another formula, similar to above for C and one for P and one for V.

Thanks
 
Is the report grouped?

A Running Total will work, as will what you tried.

Place this in the details:

whileprintingrecords;
numbervar OpenTotal;
If {POTrans.POStatus} = "O" Then
OpenTotal := OpenTotal + POTrans.LineItemTotal

In the report footer place a formula with:
whileprintingrecords;
numbervar OpenTotal

Or use a Running Total with evaluate use a formula, and each would be a type SUM, reset never, have an evaluate use a formula contaioning something like:

{POTrans.POStatus} = "O"

and be placed in the report footer.

-k
 
Thanks that did the job. The running total is the trick and I removed the If-Then statment so it is what you had mentioned. That did the job.

I tried the formula method not quite right.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top