Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Summing Values in a Grid
Message
 
À
07/01/2002 11:50:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00601514
Message ID:
00601535
Vues:
22
I'll definatly keep this in mind, however in this case there only be 10 rows at the most to sum.



>>As the user enters data into a grid column I want to be able to sum the values in that grid column and display them in a text box below the column. The control I'm using in the grid column is a textbox bound to a numeric field in a cursor.
>>
>>I put a "ThisForm.Refresh" in the controls keypress event then I put the following code in the refresh event of the screen:
>>
>>
>>LOCAL lnRecno
>>SELECT (ThisForm.cCursor)
>>lnRecno = RECNO()
>>SUM EVALUATE(ThisForm.cCursor+'.weight') to ThisForm.txtTotal.Value
>>GO lnRecno
>>
>>The problem is that the text box that contians the sum of the values does not get updated as soon as it should be. I've tried putting the code directly in the KeyPress event and in the InteractiveChange event.
>>
>>TIA
>
>Rip,
>IMHO using sum,calculate,scan..endscan etc on a grid for this purpose is unnecessary and overkill. If say you have 10K records you'd be summing all again and again. Another side effect you'd be moving the pointer and then taking it back to where you're (which might not be desired in most cases).
>
>SQL select OTOH doesn't move the pointer and you could get the sum into an array.
>-Once you sum only and only when table is updated.
>-Later you only add difference of value change affecting the sum to sumvalue.
>
>Like slow humans do it;)
>
>Cetin
Rip Ryness
International Falls, MN
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform