Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SUM function
Message
De
16/03/1998 10:33:39
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/03/1998 18:11:01
Tom Hammer
Pennwell Publishing
Tulsa, Oklahoma, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00084613
Message ID:
00084820
Vues:
56
>That didn't seem to work either. I think I'm making this harder that it is. All I want to do is show on a form the sum of a table field. I can do sum(table.field) in the command window and it works or I can use other math symbols such as + - * / within the object.controlsource, but not any of the functions such as SUM, ABS, etc.

Sum() is an aggregate function and you can use it with calculate or sql. abs() is on the other hand could be used as a normal function ie:this.controlsource = abs(customer.amt-customer.maxquota).
-Add an array prop to form (dimension as needed)
-Bind controlsources to this array elems
ie: thisform.sumfld1.controlsource = thisform.aSigma[1]
thisform.sumfld2.controlsource = thisform.aSigma[2]
-Add a custom method that would do sum (another SigmaUpdate)

*Custom form method Sigma
select sum(eExpression1), ;
sum(eExpression2),.. ;
from cTablename ;
into array this.aSigma

* Form.init
this.Sigma && Do summing on entry
* Any field's lostfocus that would effect sum
thisform.SigmaUpdate(nArrayPos,this)

* Custom form method SigmaUpdate
* nArrayPos - Position of array element effected
lParameters nArrayPos, oNumField
cFieldName = substr(oNumfield.controlsource,;
at(".",oNumfield.controlsource)+1)
cRecSource = substr(oNumfield.controlsource,1, ;
at(".",oNumfield.controlsource)-1)
nOldVal = iif(isnull(oldval(cFieldName,cRecSource)),0, ;
oldval(cFieldName,cRecSource))
nNewVal = iif(isnull(oNumfield.value),0, ;
oNumfield.value)
this.aSigma[nArrayPos] = this.aSigma[nArrayPos] ;
+ (nNewVal - nOldVal)
this.refresh

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform