Solved

Sum Condition

Posted on 2016-08-28
3
25 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 50

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 50

Expert Comment

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

/gustav
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

733 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