Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to have total for detail and header records
Message
From
21/08/2007 03:18:01
 
 
To
19/08/2007 23:28:31
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01249062
Message ID:
01249276
Views:
18
>I have a report where the order header and detail have relation. The report is grouped on orderno. The detail band has alias orderdtl. The report at the end has totals for fields from orderdtl and orderhdr table. The totals for table orderdtl are correct but the totals of orderhdr are multiplied by the numer of records in that order.
>
>Rajesh

Hi Rajesh,


Problem is that report totals are being incremented once per each
detail record and reset as specified within expression.

There are few solutions

1. You could preprocess detail cursor to include header info with invtotals
being placed only once per group of detail records. (I usuallu do that)

2. You could use (see below generic) UDF called from group header or footer (once per group) band adding invoice total amount to some predefined variable ( private or public ) and then showing that variable at the end of report.
*put folowing call in expression of dummy report textbox 
*placed in group footer
add2var('grand_total' , invoice_total )

** Generic function adding value to preexisting variable 
** to be added somewhere in main or utilities prg
function add2var 
    lparameters cTotVar,nAddVal
    &cTotVar = eval(cTotVar) + nAddVal 
    return '' &&so nothing shows on report surface

** Where 'invoice_total' is value or variable or field you  want to 
** add to report total, while 'Grand_total' is public/private variable
** (or screen/object property)  
  
And then there is also some way doing it solely with report variables but I forgot how it goes. Perhaps someone can pop up with link to thread
that shows it.

HTH
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform