Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Percent of total help
Message
From
16/05/2005 10:40:28
 
 
To
16/05/2005 10:27:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01012865
Message ID:
01014562
Views:
18
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform