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 OFFICENext 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 SummaryTableGives you...
DESCRIPTION CODE AMOUNT groupcode I_L DVD TOTAL 40000 10 X VHS TOTAL -10000 20 X OFFICE TOTAL 70000 60 XPut 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 DisplayTableNow 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 70000You 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.