>Hi Cathy:
>
>I know that you are the expert on VFP reporting (I attended some of your presentations at GLGDW), but your solution went over my head. Could you be a little more detailed?
>
>Sorry,
>
>Yossi
>
Hi Yossi,
I'll try to clarify. I went back and reread this thread and realized that I completely missed the point that you want the subtotals on the same line as the last detail line of each invoice. The solution I provided wouldn't exactly do this, so here's an altered suggestion.
1. Create a data group with an expression of MyTable.InvoiceNumber
2. Create a report variable called rnSubtotal. Initialize it as 0, set the expression to MyTable.InvoiceAmount, set the calculate option to SUM, set the ResetAt value to InvoiceNumber.
3. Create a report variable called rnGrandTotal. Initialize it as 0, set the expression to MyTable.InvoiceAmount, set the calculate option to SUM, set the ResetAt value to EndOfReport.
4. Create a report variable called rlEndOfInvoice. Initialize it to .f., set the expression to IsLastInvoice().
5. In the program that calls the report (or in a program that is in the SET PROCEDURE TO path), create a new UDF called IsLastInvoice.
FUNCTION IsLastInvoice
LOCAL lEnd, lnInvoice
lEnd = .t.
lnInvoice = MyTable.InvoiceNumber
IF NOT EOF('MyTable')
SKIP IN MyTable
lEnd = (m.lnInvoice <> MyTable.InvoiceNumber)
SKIP -1 IN MyTable
ENDIF
RETURN m.lEnd
6. In your detail band, use rnSubtotal as the expression for the subtotal object. Set the Print When logic of this object to rlEndOfInvoice so it only prints when it's the last item.
7. Create a summary band and print rnGrandTotal.
I hope this helps!
Cathy