Solved

Aggregate Function error

Posted on 2016-10-12
3
55 Views
Last Modified: 2016-10-12
Experts,

Why do I get an aggregate function error tblRepayment.ID_FAcility in the QryTEST in the attached?

SELECT qryRepaid.FacilityAmount, (Select Sum(T.Amount) From qryRepaid As T Where T.ID_Facility=qryRepaid.ID_Facility And T.ValueDate <= qryRepaid.ValueDate)-Sum([Amount]) AS [Beginning Balance], [facilityamount]-[beginning balance] AS bal
FROM qryRepaid
GROUP BY qryRepaid.FacilityAmount;

Open in new window


thank you
BalanceEE---WC.accdb
0
Comment
Question by:pdvsa
3 Comments
 
LVL 35

Expert Comment

by:PatHartman
ID: 41840838
Try putting the subtraction AROUND the subselect rather than inside it.

SELECT qryRepaid.FacilityAmount - (Select Sum(T.Amount) From qryRepaid As T Where T.ID_Facility=qryRepaid.ID_Facility And T.ValueDate <= qryRepaid.ValueDate)-Sum([Amount]) AS [Beginning Balance] AS bal
FROM qryRepaid
GROUP BY qryRepaid.FacilityAmount;
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41841017
Just add those two fields in the aggregation:

SELECT 
    qryRepaid.FacilityAmount, 
        (Select Sum(T.Amount) From qryRepaid As T 
        Where T.ID_Facility=qryRepaid.ID_Facility And T.ValueDate <= qryRepaid.ValueDate)
        -Sum([Amount]) AS [Beginning Balance], 
    [facilityamount]-[beginning balance] AS bal
FROM 
    qryRepaid
GROUP BY 
    qryRepaid.FacilityAmount, 
    qryRepaid.ID_Facility, 
    qryRepaid.ValueDate;

Open in new window

/gustav
0
 

Author Closing Comment

by:pdvsa
ID: 41841269
Hi Gustav, that works.  thank you...:)
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

860 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