Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid question
Message
From
10/07/2001 09:33:14
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgia, United States
 
 
To
09/07/2001 14:25:14
N. Lea
Nic Cross Enterprises
Valencia, California, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00528266
Message ID:
00528563
Views:
27
>I have this project and it requires the calculation of profit/loss for a company.
>Any suggestions would be helpful. Thanks!

You have a lot of pieces to put together.

First, I assume you have a program to read the account tables and come up with the basic data which is stored in a table or cursor that I'll call WorkTable.
DESCRIPTION      CODE    AMOUNT

DVD INCOME       410     50000
DVD LOSS         510     10000
VHS INCOME       420     50000
VHS LOSS         520     60000
ADMINISTRATIVE   610     40000
SALES            710     30000
I would add two fields to the table you create -which will not appear in the final grid- named groupcode and I_L (Income/Loss)and give them values like...
DESCRIPTION      CODE    AMOUNT    groupcode   I_L

DVD INCOME       410     50000      10         I
DVD LOSS         510     10000      10         L
VHS INCOME       420     50000      20         I
VHS LOSS         520     60000      20         L
ADMINISTRATIVE   610     40000      60         I
SALES            710     30000      60         I
Now you need a table that holds the GroupCode and a description. Call it GroupNames.
Code   Name
 10     DVD
 20     VHS
 60     OFFICE
Next create a cursor with the exact same structure as the table that holds the summary information. The PADR creates as Description field 25 characters wide. Adjust it to match your real description field.
SELECT PADR(GroupNames.Name + " TOTAL",25) AS Description, ;
       "   " AS CODE, ;
       IIF(I_L = "I",Amount,Amount*-1) AS Amount, ;
       GroupCode, ;
       "X" AS I_L ;
   FROM WorkTable ;
   GROUP BY GroupCode ;
   ORDER BY I_L ;
   INTO CURSOR SummaryTable
Gives you...
DESCRIPTION      CODE    AMOUNT    groupcode   I_L

DVD TOTAL                 40000      10         X
VHS TOTAL                -10000      20         X
OFFICE TOTAL              70000      60         X
Put it all together...
SELECT Description, Code, Amount, GroupCode, I_L ;
   FROM WorkTable ;
UNION SELECT Description, Code, Amount, GroupCode, I_L ;
   FROM SummaryTable ;
   ORDER BY GroupCode, I_X ;
   INTO CURSOR DisplayTable
Now display your table in a grid without the extra fields.
DESCRIPTION      CODE    AMOUNT

DVD INCOME       410     50000
DVD LOSS         510     10000
DVD TOTAL                40000 
VHS INCOME       420     50000
VHS LOSS         520     60000
VHS TOTAL               -10000  
ADMINISTRATIVE   610     40000
SALES            710     30000
OFFICE TOTAL             70000 
You can modify this to match your descriptions, and with a little creativity even add blank lines between the groups. If I understood you, the client wants to be able to append to this with drag and drop. That will take some work.

One last thought on an entirely different approach. You can create an Excel spreadsheet with summation formulas you need, instantiate in your FoxPro form and load it with the values. When the client is done, you can read the values and store changes as needed.

I haven't tested the code, but the cocept will work. At least I hope I've given you enough ideas to get you over the hurdle.
David.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform