Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to sum header field?
Message
From
27/05/2006 00:57:06
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01125187
Message ID:
01125478
Views:
15
Hi Cathy,

This is what I did:

- created a report var named nTAXTOT
- set Value To Store to ZERO (0)
- set Initial Value to ZERO (0)
- set the Calculate to SUM
- then, I put the following in On Exit Expression of the Group HEADER:
_VFP.SetVar('nTAXTOT', nTAXTOT + Invh.Tax)

It still resulted in SUMming the Tax values for every occurrence of the child table!

I moved the '_VFP.SetVar...' expression to On Entry instead - still the same.

I made an error in my thread: THIS IS ON VFP 6, NOT VFP 9... could this an issue?

Anything I could have done wrong?

Thanks
Dennis

>Create a report variable called rnTotalTax, set the initial value to zero, set the expression to zero, and then set the calculate option to SUM.
>
>In the On Exit Expression of the data group, enter the following:
>_VFP.SetVar('rnTotalTax', rnTotalTax + Invh.Tax)
>
>Now you print rnTotalTax at the end of the report.
>
>
>
>
>>Hi Guys,
>>
>>This might be a stupid question, but I am pretty much poofed out.
>>
>>I have two tables: an Invoice Header table (invh) and its Detail table (invd).
>>
>>Supposing these are the contents:
>>
>>INVH.dbf
>>InvNo Date Tax Amount
>>001 5/11 100.00 1000.00 - has 2 child recs
>>002 5/13 125.00 1250.00 - has 1 child rec
>>003 5/25 80.00 800.00 - has 3 child recs
>>004 5/26 50.00 500.00 - has 1 child rec
>>
>>INVD.dbf
>>InvNo Prodcode Qty Price
>>001 A1 Some value...
>>001 B2 Some value...
>>002 B1 Some value...
>>003 B1 Some value...
>>003 C3 Some value...
>>003 C4 Some value...
>>004 A5 Some value...
>>
>>- I then created a report form to list all the invoices and the respective details.
>>- The report is grouped by InvNo
>>- INVH is related into INVD via InvNo (obviously)
>>- SET SKIP TO InvD is also enforced (which means each header will be in effect for every matching detail record)
>>
>>Question: How do I get the total TAX value using a report variable? In the example above it should amount to 355.00. Since I use SET SKIP, the total I get is wrong since the tax value is added for every matching child record.
>>
>>Thanks and God bless.
>>
>>Dennis
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform