Solved

Sum Condition

Posted on 2016-08-28
3
18 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
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
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
Comment Utility
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 49

Expert Comment

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

/gustav
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now