Calculating Age, storing Age, and keeping it up-to-date

Morpheus_UK

Registered User.
Local time
Today, 16:39
Joined
Dec 31, 2004
Messages
23
Ok, I have a table called MAIN which includes the 2 fields DOB and AGE. So far I can calculate Age field by running this Update Query:

Field: Age
Table:MAIN
Update to: DateDiff("yyyy",[DOB],Date())+Int(Format(Date(),"mmdd")<Format([DOB],"mmdd"))

Is there a way to have this Query run everytime the Database is opened, automatically? Also, how would I then avoid the problem of Msg boxes poping up asking if I want to Update peoples records (concerning Age). I don't want this asked, cos its obvious I want Age up-to-date, I don't want to be asked. So how would this be done?

If there is another method for keeping an Age field in a table up-to-date based on the DOB field, please let us know. Any help will be well recieved. :)
 
The method for keeping the age up to date is to NEVER STORE IT. Instead, when you need age, obtain it through a calculation. Look up DateDiff as one way to do this in a query, then remember that anything a table can do, a query can usually do better - except store raw data.
 
Ok I was going to have a search option, that would ask for an age e.g. the User would enter 21 and a query would run finding records with containing 21 or higher from their age field.

So if I want a database where you can search for people at and over a certain age I can do this without storing the age, how should I go about this?
 
Its Ok, I will be leaving that option out, I'm sure if I have a better search on these forumns and the internet I will find out. Cheers again Doc_Man
 

Users who are viewing this thread

Back
Top Bottom