Solved

Need help resolving aggregate function error in totals query in Access.

Posted on 2012-03-13
7
339 Views
Last Modified: 2012-03-13
Here is the query I'm trying to run;
query
Here is the sql;
SELECT Sum(dbo_View_LaborDtl.ldLaborHrs) AS SumOfldLaborHrs,
Sum(dbo_View_LaborDtl.ldEarnedHrs) AS SumOfldEarnedHrs,
IIf([ldLaborRate]=0,[ebLaborRate],[ldLaborRate]) AS AdjLaborRate,
Round16([ldLaborHrs]*[AdjLaborRate],2) AS ldAmount
FROM dbo_View_LaborDtl
LEFT JOIN dbo_View_EmpBasic
ON dbo_View_LaborDtl.ldEmployeeNum = dbo_View_EmpBasic.ebEmpId
WHERE (((dbo_View_LaborDtl.ldPayrollDate)>=Eval('[Forms]![frmCSLPL]![txtStartDate]')
And (dbo_View_LaborDtl.ldPayrollDate)<=Eval('[Forms]![frmCSLPL]![txtEndDate]'))
AND ((dbo_View_LaborDtl.ldLaborType)<>"I") AND ((dbo_View_LaborDtl.ldLaborHedSeq)<>0));


And here is the error I'm getting;

error
Thanks in advance for the help!
0
Comment
Question by:SeyerIT
[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
  • 3
  • 3
7 Comments
 
LVL 11

Expert Comment

by:Runrigger
ID: 37714220
Try this, basically, you are trying to sum two fields, but not sum the two remaining ones, I have made an assumption that you need to sum all 4 of the returned fields.

SELECT Sum(dbo_View_LaborDtl.ldLaborHrs) AS SumOfldLaborHrs,
Sum(dbo_View_LaborDtl.ldEarnedHrs) AS SumOfldEarnedHrs,
Sum(IIf([ldLaborRate]=0,[ebLaborRate],[ldLaborRate])) AS AdjLaborRate,
Sum(Round16([ldLaborHrs]*[AdjLaborRate],2)) AS ldAmount
FROM dbo_View_LaborDtl
LEFT JOIN dbo_View_EmpBasic
ON dbo_View_LaborDtl.ldEmployeeNum = dbo_View_EmpBasic.ebEmpId
WHERE (((dbo_View_LaborDtl.ldPayrollDate)>=Eval('[Forms]![frmCSLPL]![txtStartDate]')
And (dbo_View_LaborDtl.ldPayrollDate)<=Eval('[Forms]![frmCSLPL]![txtEndDate]'))
AND ((dbo_View_LaborDtl.ldLaborType)<>"I") AND ((dbo_View_LaborDtl.ldLaborHedSeq)<>0));
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37714228
try replacing "Expression" with "Last" or "First"
0
 
LVL 2

Author Comment

by:SeyerIT
ID: 37714236
Runrigger, I tried your sql and am getting the following error;
Capricorn, I also tried your method and got the same error.
error
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 11

Accepted Solution

by:
Runrigger earned 500 total points
ID: 37714252
Try this.

SELECT Sum(dbo_View_LaborDtl.ldLaborHrs) AS SumOfldLaborHrs,
Sum(dbo_View_LaborDtl.ldEarnedHrs) AS SumOfldEarnedHrs,
Sum(IIf([ldLaborRate]=0,[ebLaborRate],[ldLaborRate])) AS AdjLaborRate,
Round16(Sum([ldLaborHrs]*IIf([ldLaborRate]=0,[ebLaborRate],[ldLaborRate])),2) AS ldAmount
FROM dbo_View_LaborDtl
LEFT JOIN dbo_View_EmpBasic
ON dbo_View_LaborDtl.ldEmployeeNum = dbo_View_EmpBasic.ebEmpId
WHERE (((dbo_View_LaborDtl.ldPayrollDate)>=Eval('[Forms]![frmCSLPL]![txtStartDate]')
And (dbo_View_LaborDtl.ldPayrollDate)<=Eval('[Forms]![frmCSLPL]![txtEndDate]'))
AND ((dbo_View_LaborDtl.ldLaborType)<>"I") AND ((dbo_View_LaborDtl.ldLaborHedSeq)<>0));
0
 
LVL 2

Author Closing Comment

by:SeyerIT
ID: 37714259
That works! Thanks for the help!
0
 
LVL 11

Expert Comment

by:Runrigger
ID: 37714281
a pleasure, and thanks for the points
0
 
LVL 2

Author Comment

by:SeyerIT
ID: 37714283
No problem!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

691 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