Marsh,
This was excellent!!! Thank you so much!!!
Now, your answer begs the question, how to do this with uneven intervals?
Ideally, i'd like to pull data on the following intervals:
0 – 2 years
3 – 5 years
6 – 10 years
11 – 15years
16 – 20years
21 – 25years
26 – 29years
30 – 39years
40 – 49years
50 – 59years
60 – 69years
>70years
Marshall Barton - 28 Sep 2005 00:09 GMT
>This was excellent!!! Thank you so much!!!
>
[quoted text clipped - 13 lines]
>60 69years
>>70years
Write you own function to return the age bracket or create a
table to define the brackets. Since I don't want to have to
edit code when some executive mind/mood changes, I woud use
the table approach:
table AgeGroups:
Bracket Text PK
Low Integer
High Integer
Populate the table's records:
0-2 0 2
3-5 3 5
. . .
Then in your report's record source query, Join the
AgeGroups table using:
SELECT T.lastname, T.gender, T.age, A.Bracket, . . .
FROM table As T LEFT JOIN AgeGroups As A
ON T.age Between A.Low And A.High
The report can then group on the expression Val(Bracket) and
the text box would just be bound to the Bracket field.
Note that you can not specify that kind of Join in the query
design grid, so you have to edit the query in SQL view.

Signature
Marsh
MVP [MS Access]
janaki - 28 Sep 2005 16:09 GMT
Thanks so much for the help.........clarification on the SELECT syntax:
getting the error message "Between operator without And in query expression
'T.age Between A.Low'.
but this works:
SELECT T.gender, T.age, A.Bracket
FROM table AS T LEFT JOIN AgeGroups AS A ON (T.age>=A.Low) AND
(T.Age<=A.High);
> Then in your report's record source query, Join the
> AgeGroups table using:
[quoted text clipped - 8 lines]
> Note that you can not specify that kind of Join in the query
> design grid, so you have to edit the query in SQL view.
Marshall Barton - 03 Oct 2005 15:46 GMT
>Thanks so much for the help.........clarification on the SELECT syntax:
>getting the error message "Between operator without And in query expression
[quoted text clipped - 4 lines]
>FROM table AS T LEFT JOIN AgeGroups AS A ON (T.age>=A.Low) AND
>(T.Age<=A.High);
Interesting that there's a version of the query parser(?)
that doesn't recognize Between, but It's good to hear that
you found an equivalent expression that works.

Signature
Marsh
MVP [MS Access]
Duane Hookom - 28 Sep 2005 00:13 GMT
You begin by assuming the intervals will change over time. Perhaps the
quickest method is to create a function in a general module named
"modBusinessCalcs"
Public Function GetAgeInterval(pintAge as Integer) as String
Select Case pintAge
Case is < 3
GetAgeInterval = "0 - 2 years"
Case 3 to 5
GetAgeInterval = "3 - 5 years"
Case 6 to 10
GetAgeInterval = "6 - 10 years"
'... etc...
End Select
End Function
Then you can use this function in queries, control sources, code,...
AgeInterval: GetAgeInterval([Age])
If you want to allow users to modify the age intervals, you need to create a
table that allows for a lookup.

Signature
Duane Hookom
MS Access MVP
--
> Marsh,
> This was excellent!!! Thank you so much!!!
[quoted text clipped - 14 lines]
> 60 - 69years
>>70years