On Tue, 24 Aug 2010 18:21:28 -0400, "LAS" <(E-Mail Removed)> wrote:
>I get this error
>"You tried to execute a query that does not include the specified expression 'ProbBehaveCat1_Desc' as part of an aggregate function."
>
>when I execute query 2. Query 1 works fine. Before Access blew up on me, a function that produced Query 2 also worked fine. HELP!!! Can anyone figure out what might be wrong?
>
>QUERY 1 - typed directly into the query builder
>SELECT Sum(fncElapsedTime(Incident_Time,Incident_Return_Time)) AS Expr1, tblStudentTracking.ProbBehaveCat1_Desc
>FROM tblStudentTracking, tblStudents
>WHERE tblStudents.Student_ID=tblStudentTracking.Student_ID
>And tblStudentTracking.Student_ID=374
>And nz(tblStudentTracking.ProbBehaveCat1_Code,'')='xOther'
>GROUP BY tblStudentTracking.ProbBehaveCat1_Desc
>ORDER BY tblStudentTracking.ProbBehaveCat1_Desc;
>
>
>QUERY 2 - Cut and pasted from Immediate View in a function that builds this query string (end of line inserted by me)
>SELECT Sum(fncElapsedTime(Incident_Time,Incident_Return_Time)) AS Expr1, tblStudentTracking.ProbBehaveCat1_Desc
>FROM tblStudentTracking, tblStudents
>WHERE tblStudents.Student_ID=tblStudentTracking.Student_ID
>and tblStudentTracking.Student_ID = 374
>And nz(tblStudentTracking.ProbBehaveCat1_Code,'')='xOther'
>GROUP BY tblStudentTracking.ProbBehaveCat1__Desc
>ORDER BY tblStudentTracking.ProbBehaveCat1__Desc;
Are you intending Desc to mean "sort in descending order"? What in fact is the
field name in your table... ProbBehaveCat1 or something else?
If my guess is correct try
SELECT Sum(fncElapsedTime(Incident_Time,Incident_Return_Time)) AS Expr1,
tblStudentTracking.ProbBehaveCat1
FROM tblStudentTracking, tblStudents
WHERE tblStudents.Student_ID=tblStudentTracking.Student_ID
And tblStudentTracking.Student_ID=374
And nz(tblStudentTracking.ProbBehaveCat1_Code,'')='xOther'
GROUP BY tblStudentTracking.ProbBehaveCat1
ORDER BY tblStudentTracking.ProbBehaveCat1 Desc;
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also
http://www.utteraccess.com