Expression help continued

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
 
K

Ken Snell \(MVP\)

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dsum cont: 1
Expression subtracts double 4
Help with expression 4
Help with DSUM 3
ACCESS 2007 Running Balance in query 4
Mail Merge Help 1
Expression 0
Expression 1

Top