Try:
PARAMETERS [Begin Date] DateTime, [End Date] DateTime;
SELECT Nz(Registration.Age, "Blank") AS RegistrationAge,
Count(Registration.Age) AS RegistrationCount
FROM Registration
WHERE (((Registration.[Date Attended])<=[End Date]
And (Registration.[Date Attended])>=[Begin Date]))
GROUP BY Registration.Age;
Presumably for the records where Age isn't filled in, the field actually
contains Null. To be honest, though, I would have expected them to appear
on your report, since you're not filtering on Age (filtering on Null
values requires slightly different syntax). Are you sure there are
records with no age in the date range you're looking at?
Using AS after a field name allows you to use whatever alias you want for
the field.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Bob Watson said:
Thanks - that helped tremendously ... my
actual query looks like this:
PARAMETERS [Begin Date] DateTime, [End Date] DateTime;
SELECT Registration.Age, Count(Registration.Age)
FROM Registration
WHERE (((Registration.[Date Attended])<=[End Date] And
(Registration.[Date Attended])>=[Begin Date]))
GROUP BY Registration.Age;
with this query output:
Age Expr1001
0
20-24 29
25-34 125
35-44 116
45-64 55
Couple of observations/questions:
1 - the count of a "Blank Age" is not 0. Why is
the "blank count" not working?
2 - I suppose this output could be used as a
"Record Source" of a Report. Can I change the
column name of Expr1001 to "Number" ??
Thanks in advance,
Bob
You want to count the number of Records by AgeRange so you need to use
an Aggregate Query (with Group By) clause on your Table with SQL String
like:
SELECT Count([YourTable].[Name])
FROM [YourTable]
GROUP BY [YourTable].[AgeRange]
--
HTH
Van T. Dinh
MVP (Access)
I have a report that gives name and age range.
Such as
Bob 30-35
Bill 30-35
Tom 36-40
Betty 36-40
Mary 36-40
What I want are recaps and no details.
Such as
30-35 2
36-40 3
I cannot figure out how. "Access For Dummies"
did not come thru in this instance.
TIA,
Bob