Avatar of pdvsa
pdvsa
Flag for United States of America asked on

Summing on a form

Experts,

How can I modify this in a textbox on a form:
=Sum([tblPayments.Amount])

To only sum if NotPaidYN = False
In other words, I only need to sum the tblPayments.amount if NotPaidYN = False


thank you
Microsoft Access

Avatar of undefined
Last Comment
pdvsa

8/22/2022 - Mon
Gustav Brock

Like this:

=Sum(IIf(Not [NotPaidYN],[tblPayments.Amount],0)) 

Open in new window


Ryan Chong

I believe what Gustav mentioned should resolved your issue?

Just in case if it doesn't and you mean to "sum all relevant amount values if its correspondence's field: NotPaidYN = False", then use DSUM function instead.

DSum ( expr , domain [, criteria] )

such as:
=DSum("Amount", "tblPayments", "NotPaidYN = False")

Open in new window


more details

DSum Function
https://support.microsoft.com/en-us/office/dsum-function-08f8450e-3bf6-45e2-936f-386056e61a32?ui=en-us&rs=en-us&ad=us
pdvsa

ASKER
Ryan,... understood.  Thanks for the tip.

Gustav: do I need an extra parenthesis or something else?  I am getting wrong number of arguments and I have tried many combinations.

Thank you
Typing from phone.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dale Fye

Personally, I avoid negatives in field and variable names, it just makes them harder to deal with and understand in your code.
Instead of [NotPaidYN] I would have used [PaidYN]

Dale

pdvsa

ASKER
It was #1.  Thanks!  works perfectly.  
pdvsa

ASKER
Dale, makes total sense.  I will change it.  
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.