Solved

Sum Condition

Posted on 2016-08-28
3
27 Views
Last Modified: 2016-08-28
Experts, I am trying to sum tblDraws_Details1.Amount + tblRepayment.Amount but only where tblRepayment.PaymentMadeYN = 'Yes'  (its text).  Meaning that I will add only tblRepayment.Amount to each tblDraws_Details1.Amount but only if tblRepayment.PaymentMadeYN = 'Yes'
YOu can see in the Select statement I do not have any condition for this.  
Please let me know if not clear.

thank you

SELECT
     tblRepayment.ID, tblRepayment.DrawIDrpmt, tblRepayment.PaymentMadeYN, tblDraws_Details1.Amount, tblRepayment.Amount, [tblDraws_Details1.Amount]+[tblRepayment.Amount] AS Balance
FROM
     tblDraws_Details1 INNER JOIN tblRepayment ON tblDraws_Details1.ID = tblRepayment.DrawIDrpmt
ORDER BY
     tblRepayment.DrawIDrpmt;
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41773824
That could be:
SELECT 
     tblRepayment.ID, 
     tblRepayment.DrawIDrpmt, 
     tblRepayment.PaymentMadeYN, 
     tblDraws_Details1.Amount, 
     tblRepayment.Amount, 
     [tblDraws_Details1.Amount]+IIf(tblRepayment.PaymentMadeYN="Yes",[tblRepayment.Amount],0) AS Balance
FROM 
     tblDraws_Details1 
INNER JOIN 
     tblRepayment 
     ON tblDraws_Details1.ID = tblRepayment.DrawIDrpmt
ORDER BY 
     tblRepayment.DrawIDrpmt; 

Open in new window

/gustav
0
 

Author Closing Comment

by:pdvsa
ID: 41773843
Nice.  I took a piece from another one you answered the other day and came up with this:
....DSum("Amount","tblRePayment","DrawIDrpmt = " & [DrawIDrpmt] & " and PaymentMadeYN = 'Yes'")

I discovered that I needed a Dsum and i remembered the one from the other day that was very similar.  I actually tried that one from the other day but it wasnit giving me what I needed so I kept modifying and modifying til I asked a question on EE.

thank you.   I hope my questions on this topic are coming to an end.  Have a good night!
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 41773845
You are welcome - and a very good night for you too!

/gustav
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question