Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#285665 - 18/08/2006 11:32 MS Access... calculating someone's age?
CrackersMcCheese
pooh-bah

Registered: 14/01/2002
Posts: 2489
In table design view, I have my list of 'things', one of which is date of birth. I want another field to return the age of the individual automatically in years but I can't seem to do it (its probably so simple and obvious and I'm thinking about it too much). Anyone able to assist?

Top
#285666 - 18/08/2006 11:40 Re: MS Access... calculating someone's age? [Re: CrackersMcCheese]
Mach
old hand

Registered: 15/07/2002
Posts: 828
Loc: Texas, USA
Table data is typically static; age is not. It would be better to handle the age calculaton in a query, or create an update query to update the age in the table on demand, or you just calculate it in your form or report.

Top
#285667 - 18/08/2006 11:55 Re: MS Access... calculating someone's age? [Re: Mach]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5915
Loc: Wivenhoe, Essex, UK
The query is definitely the way to go.

If I have a table with the fields id and dob in then the query needed is:

SELECT id, dob, DateDiff('yyyy',[dob],Now()) AS Age
FROM people;

Because of the way Access treats Queries almost the same as Tables you can then create Forms based on the query you have created and the Age field in the query (and the form) will get calculated as soon as you fill in the date of birth.
_________________________
Remind me to change my signature to something more interesting someday

Top
#285668 - 18/08/2006 12:18 Re: MS Access... calculating someone's age? [Re: andy]
CrackersMcCheese
pooh-bah

Registered: 14/01/2002
Posts: 2489
Cheers guys! Sorted!

Top