Expression help continued

  • Thread starter Thread starter myxmaster
  • Start date Start date
M

myxmaster

I have the following expression:

=DSum("Amount", "YourTable", "TransactionType = ""Credit""") -
DSum("Amount", "YourTable", "TransactionType = ""Debit""")

However if there is NO Debit transaction the expression does not work.
What do I have to do to have it reflect all credits and IF there is a
Debit to adjust accordingly

TIA
 
If there are no debits, the second DSum function returns a Null value, which
then propagates through the mathematical calculation, resulting in a Null
value for the subtraction. Use the Nz function to replace the Null value
with a zero value:

=DSum("Amount", "YourTable", "TransactionType = ""Credit""") -
Nz(DSum("Amount", "YourTable", "TransactionType = ""Debit"""),0)
 
Back
Top