Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Percent of total help
Message
 
À
16/05/2005 10:27:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01012865
Message ID:
01014562
Vues:
19
Here, old way with pure xBase commands, except CREATE CURSOR: (not tested)
CREATE CURSOR crsResult (account C(10),amount N(15,2), percentage N(6,2), ClassCode C(5))
SELECT MyTable
INDEX ON Account+ClassCode TAG MyTable && With proper conversion if they are different types
SET ORDER TO MyTable
GO TOP
DO WHILE .NOT. EOF()
   m.nRecNo      = RecNo()
   m.changedCond = Account+ClassCode && With proper conversion if they are different types
   SUM Ammount TO nTotalAmm WHILE m.changedCond == Account+ClassCode
   GO m.nRecNo
   DO WHILE m.changedCond == Account+ClassCode
      *** You need to check IF the nTotalAmm is not equal to zero.
      SELECT crsResult
      APPEND BLANK
      REPLACE Account    WITH MyTable.Account,;
              Ammount    WITH MyTable.Ammount,;
              ClassCode  WITH MyTable.ClassCode,;
              Percentage WITH IIF(nTotalAmm==0,100,ROUND(Ammount/nTotalAmm,2))
      SELECT MyTable
      SKIP
   ENDDO
ENDDO
Why you should do that? I am not very familiar with VBA but doesn't it supports SQL-SELECT commands?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform