I think you might want the following.
SELECT GDate, Count(Grades) as Lessons
FROM Grades
WHERE Grade >= 0
GROUP BY GDate
However, it seems looking a DTotalLessons that you may have more than just the
grades table involved.
When I look at your query, I really don't understand why it is giving you 5000
records instead of the 20 you expect. It should be returning the 20 you expect,
unless the calculated value for lessons is varying.
Chaplain said:
Dear John:
When I run
SELECT DISTINCT GDate FROM Grades;
I get about twenty distinct dates on which our graders posted grades. When
I use:
SELECT DISTINCT GDate, DTotalLessons([GDate]) AS Lessons FROM Grades;
I get about 5,000 records returned, one for each grade entered in the
database.
What I am after is just twenty records returned, one for each distinct date
along with the total number of lessons graded on that date. The number is
returned by the DTotalLessons function.
The function DTotalLessons is as follows:
Public Function DTotalLessons(DDate As Date)
DTotalLessons = DCount("[GDate]", "[Summary Query]", "[GDate]=#" +
CStr(DDate) + "# AND [Grade]>=0")
DTotalLessons = DTotalLessons + DCount("[GDate]", "[Summary Query
Archive]", "[GDate]=#" + CStr(DDate) + "# AND [Grade]>=0")
End Function