Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to cumulate totals of my view without loosing cur. r
Message
De
05/11/1999 08:05:34
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00286872
Message ID:
00287394
Vues:
19
>I have a view that I use to input data in a grid. In the amount field, valid method, I want to recalculate the totals by cumulating the amount in each record of the current view. The problem is that it makes me loose my current pointer.
>
>How can I achieve this?
>Thanks
>Eric


Eric,
It's nonsense to recalculate the totals in a grid from a valid. Because after an initial calculation, your totals would only be affected by fields that contribute to total. Recalculation is time consuming and needs you should be carefull about your buffering, record pointer movement etc etc. Instead I suggest do calculation once per parent rec change (if this is a child). Later in your valid just change the total.
* Addition to method code where parent recchange occurs
* A custom form array aSums holds sum for fields
* At this point since you're changing parent
* there should be no data in buffer - tableupdated
select sum(f1), sum(f2), sum(fn) ;
  from myTable ;
  where linkfield = parent.pkfield ;
  into array thisform.aSums
if _tally = 0
  dimension thisform.aSums[3,1]  && Safety belt
  thisform.aSums = 0
endif

* Controls with controlsource Fields that affect sum gotfocus or when
this.Tag = str(this.value)  && Tag property is a ready storage place

* Controls with controlsource Fields that affect sum lostfocus or valid
* Assume this is f2 field
thisform.aSums[2,1] = ;
   nvl(thisform.aSums[2,1],0) ;
   - val(this.tag) + this.value
No record pointer movement, no time consuming (well ignoring little time spent here for math). If your total showing textboxes have thisform.aSums[x,1] as controlsources that's all you need. No need for a refresh.
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