Help with DSUM

M

myxmaster

I have the following in a unbound text box.

=DSum("[Amount]", "YourTable", "[TransactionType] = ""Credit""") -
DSum("[Amount]", "YourTable", "[Status] = ""Cleared""")

This works however not until I put cleared in the status in the field.
If I have 10 credit transactions nothing will show however as soon as
I enter 1 cleared it will show that transaction. What I need to do is
show all the transactions however if cleared is entered then it will
remove that total from the sum.
TIA
 
E

EeOr

Hi, this looks like a problem with Nulls perhaps you should try the NZ
function I haven't tested this but try:

=DSum("[Amount]", "YourTable", "[TransactionType] = ""Credit""") - NZ(
DSum("[Amount]", "YourTable", "[Status] = ""Cleared"""))

That way if the DSUM of cleared transactions is null it will use 0 instead.

Jon
 
M

myxmaster

Jon
Perfect. Thanx for the quick reply, I have been looking at this for
days.
Jerry said:
Hi, this looks like a problem with Nulls perhaps you should try the NZ
function I haven't tested this but try:

=DSum("[Amount]", "YourTable", "[TransactionType] = ""Credit""") - NZ(
DSum("[Amount]", "YourTable", "[Status] = ""Cleared"""))

That way if the DSUM of cleared transactions is null it will use 0 instead.

Jon


I have the following in a unbound text box.

=DSum("[Amount]", "YourTable", "[TransactionType] = ""Credit""") -
DSum("[Amount]", "YourTable", "[Status] = ""Cleared""")

This works however not until I put cleared in the status in the field.
If I have 10 credit transactions nothing will show however as soon as
I enter 1 cleared it will show that transaction. What I need to do is
show all the transactions however if cleared is entered then it will
remove that total from the sum.
TIA
 
A

Al Campagna

If there were no Cleared entries, I would have expected Sum of Amount to return Null,
which hould have caused an #Error.

But, try this...
=NZ(DSum("[Amount]","tblYourTable","TransactionType = ""Credit""")) -
NZ(DSum("[Amount]","tblYourTable","Status= ""Cleared"""))

Didn't have time to test, but that should do it...
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 

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

Help with expression 4
Dsum cont: 1
Expression subtracts double 4
Expression help continued 1
DSUM QUESTION 1
Dsum Issues 0
DSum 1
dsum - 1

Top