Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum of Grid Column
Message
De
26/06/1998 03:13:32
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
25/06/1998 23:15:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00111764
Message ID:
00111845
Vues:
14
>>>I have a grid which the user can add records to a child table. Does VFP have a method for calculations on columns and/or rows. I would like to sum a numeric column without having to access the child table. Any help is greatly appreciated.
>>>
>>
>>No method so far. I would suggest a custom method be created and do the calculation by SELECT-SQL to make it independent with the source table, thus, no direct access on the data and so record pointer will not change. The Method is actually a wish list of mine on the upcoming version releases because PB Data Window is supporting that feature.
>
>Thanks for the assistance. SQL will work just fine...
>
>Jamie
Jamie,
For rowwise calculation you could use calculated fields (ie: controlsource = field1+field2 - Readonly). For columnwise SQL is the best way. To speed up things :
* Custom method that would be called as parent rec changes
select sum(myfield) ;
  where linkkey = parentPK ;
  into array myarray
thisform.sumcolumn.value = iif(type("myarray")="U",0,myarray[1])

* Myfield.valid
* Buffering is most likely on with VFP 5
nOldValue = nvl(oldval("myfield"),0)
nNewValue = nvl(myfield,0)
thisform.sumcolumn.value = ;
   thisform.sumcolumn.value + (nNewValue - nOldValue)
So SQL would only be called if parent rec changes.
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