Solved

Aggregate Function error

Posted on 2016-10-12
3
42 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 34

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

Suggested Solutions

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
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…
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…

948 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

22 Experts available now in Live!

Get 1:1 Help Now