Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using SUM, COUNT, etc. in a form with multiple tables
Message
De
05/11/1998 12:13:48
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/11/1998 08:19:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00154405
Message ID:
00154882
Vues:
16
Yes for sure. But since this is for grid summing on the fly it's enough and fast to get just back-end values. A simple :
sumvalue = sumvalue - this.value on gotfocus
sumvalue = sumvalue + this.value on lostfocus work quite well.
Cetin

>Problem with SQL is that it won't work on buffered tables ... picks up the "back-end" values - not the current buffered ones
>
>>>>>>I have a form with several tables in its data environment. If I want to use SUM to sum a field in one particular table, what should I do? (How can you specify the table in SUM command?) Is there any better way to get a sum of a field in a table without worrying working area while multiple tables exist in a data environment? Thanks in advance.
>>>>>You can use SQL to sum to an array. So won't worry about current workarea, rec pointer movement etc. ie: select sum(sumfld1), sum(fld2*fld3/3) into array aSums. Further you could set array elements as controlsources of textboxes that would show the sum (so no need for refresh too :).
>>>>>Cetin
>>>>
>>>>Thank you, Cetin. But is there any better way than using SQL? The reason for asking this is that I have multiple tables in the form. When SQL runs it changes the work area which is the whole point that I am trying to avoid.
>>>>
>>>>I use a field to show the currect sum of some records in a table(grid) which is editable on the form. In other words, I want to have a textbox on a one-to-many form. Whenever I add/delete/change records in the grid (detail table) or I move the records in the master table, the updated sum of related records in the detail table will be displayed in the textbox.
>>>
>>>
>>>If you SQL to an ARRAY, it does NOT change the selected area. This is what Cetin suggested that you do.
>>>
>>>Fred
>>
>>
>>Good point, Fred. Thank you. Cetin, thank you again.
>>
>>Wei
Ç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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform