Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using SUM, COUNT, etc. in a form with multiple tables
Message
De
09/11/1998 01:01:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
08/11/1998 21:21:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00154405
Message ID:
00155633
Vues:
25
Add an array property to form. To do it select form\new property and define property as aMyArray[1]. After SQL you could do a acopy(aSQL,thisform.aMyArray).
BTW "SQL won't sum buffered values" is true but there is no way to get changed values that are buffered in other stations. Further it could be the same record being edited in other station, if you'll let edition of childs belonging to same parent at the same time. Good luck.
Cetin
>If it is in the case of multiple users working on the same table, this approach won't show the change made by the other person, I am afraid. In my case, I base on back end data.
>
>Well, once again, thank you all very much for the respose to my original question. Here, I have another question. If I want to have an array shared by all the methods in a form and encapsulated only in this form, where should I define the array?
>
>Wei Lin
>
>
>>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
Répondre
Fil
Voir

Click here to load this message in the networking platform