I'd assume you do this to get a balance of debits and credits after individual transactions (records)?
If so I'd just create a formula field as follows and then create a running total on this field;
if {table.typefield} = "c" then -{table.amountfield} else
if {table.typefield} = "d" then {table.amountfield}
You may need to change the "-" position - You should be able to create a running total on this field on each record resetting at customer/supplier or whatever you need.
If I'm misunderstanding what you're trying to accomplish let me know.
Regards,
Ryan.