View Full Version : Help with an expression in MS Access, please


Grahamfff
01-10-2007, 08:53
I have a large database / mailing list in which I have a field recording each person's date of birth. I then have a calculated field which returns that person's age

What I would like is to add a calculated field which tells me which age group each individual falls into (ie age 0-9; 10-19, 20-29 and so on).

I know that the following expression will divide the mailing list into two groups (under and over 50s) but it won't give me what I want:

Age Group: IIf([Age]>49,"50+","Under 50")

I'm not sure that what I want is actually possible - or at least I might have to go about it in a radically different way.

Can anyone help.

Many thanks.

Nazo
01-10-2007, 09:31
You could nest IIf statements to get what you want:

eg. IIf([Age]<10,"0-9",IIF([Age] <20, "10-19", IIF(...))) and so on until you have all your groups covered, it doesn't look too pretty but will do what you want.

Grahamfff
01-10-2007, 10:04
Thanks very much for that - it does work, except that to divide the ages into as many bands I want, I exceed the limit of 256 characters in a string - but I can work around that.

Thanks again