Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Total a grid column
Message
De
18/11/1999 01:37:06
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
17/11/1999 12:30:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00291973
Message ID:
00292298
Vues:
26
>I have a form with two grids, grid1- parent employee file,
>grid2- child activity file.
>
>I have a textbox to hold the sum of activity.hours, but it seems to just display the final record value, not the sum. Here's the code I have in RowChange of Grid1:
>
>gcSeekVal = employeeno
>calculate sum(activity.hours) to thisform._textbox1.value for activity.employeeno=gcSeekVal
>seek gcSeekVal &&this is just to keep pointer on employee clicked
>
>What obvious thing have I missed. (Tick, tick, tick, Y2K clock)
>
>Thanks in Advance,
>Sylvia


Sylvia,
When there is parent-child relation I prefer to sum once per parent rec change. Then sum is only affected by the field contributing it. So implementing this approach to your tables :
* Employee grid.afterrowcolchange
select sum(hours) from activity ;
 where employeeno = employee.employeeno ;
 into array aSum
thisform._textbox1.value = iif(type("aSum[1,1]") # "N", 0, aSum[1,1])

* Activity.grid.hourscolumn.gotfocus
this.tag = str(this.value)

* Activity.grid.hourscolumn.lostfocus
thisform._textbox1.value = ;
  thisform._textbox1.value - val(this.tag) + this.value
This has the advantage that you don't need to check record pointer movement and fast even with thousands of child records.
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