Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subtotals and totals
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01135680
Message ID:
01135766
Views:
11
>Rather than trying to fix what I've apparently done wrong, can someone just tell me how to do it correctly from the start?
>
>Here are some of the fields in my cursor:
>
>order_no, qty, price, frt
>
>Here are a few sample records for order #100:
>
>100, 10, 1.23, 50
>100, 20, 2.00, 50
>100, 10, 1.50, 50
>
>As you can see, "frt" is in each record, but is the total freight for the order.

Any time you use the "calculate" option in the report writer, it is going to process the calculation once for each detail record. Obviously, this isn't what you want for freight because you only want to process it once per order.

If you have a data group on the Order Number, which I suspect you do, give this a try. Add a report variable called rnTotalFreight. Set the value to zero, the calculate option to SUM, and the reset value to End of Report.

Now in the OnExit expression of the data group footer band, enter the following:
_VFP.SetVar('rnTotalFreight', rnTotalFreight + frt)
What this concept does is create a report variable that does nothing more than add zero to itself each time it processes a detail band. However, you manually manipulate the variable at the end of each "group" and increase it by the amount of the freight. Now you are only adding the freight once for each order.
Cathy Pountney, Microsoft Visual FoxPro MVP
Memorial Business Systems, Inc. (www.mbs-intl.com)

My Website: (www.frontier2000.com)
My Blog: (www.cathypountney.blogspot.com)
My Book: The Visual FoxPro Report Writer - Pushing it to the Limit and Beyond
Free MSDN Article: What's New in the VFP 9.0 Report Writer
Free MSDN Article: The VFP 9.0 Report Writer In Action
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform