How to make an age entry stay current?

Ani

Registered User.
Local time
Today, 23:47
Joined
Mar 10, 2012
Messages
196
Hi
I have just started to create forms for my tables. I have a couple of data entries that are age related.
Can someone please tell me if it is possible to keep the age current with present day?
eg If I enter the age of a horse today as 9 yrs 4mths and this time next year the horse will be 10 yrs 4mths. What data type should I use (in the Table)? And how do I tell the data to stay current with the present date?
If possible I would like to keep the entry current in months as well as years.
Thank you
Ani
PS I do not want to have to run a query each time to calculate the age if I can avoid it
 
Last edited:
Instead of entering the age, enter the birth date and have Access calculate the age. In that manner it is always current.

Here is a tutorial on that.

http://www.fontstuff.com/access/acctut05.htm

You would have to modify it slightly to give the results in a different format.

Alan
 
If you want a little more accurate.

Age: DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB])))
 
If you want a little more accurate.

Age: DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB])))

Thank you! I do not understand where I put that but I will work it out! LOL

Im trying to design the actual forms so will make more of an attempt to work out what to do with the instruction/code in a little while!
Very confused atm!

Ani xx
 
Copy and paste it into a Query.

If you have a Field DOB then it should work.
 
Copy and paste it into a Query.

If you have a Field DOB then it should work.

Thank You! Im obviously jumping a bit ahead of myself because Im not ready to start queries yet! I will modify the fields to DOB where needed though, now!
Im a bit confused as to what I should do after creating and normalising tables. Should I do queries or forms or something else first?
Cheers
Ani
 
I suggest you create a Form which will require a Query, so create the query.
 
If you want a little more accurate.

Age: DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB])))

Hiya
Please advise if I am doing something wrong? I have copied and pasted above into my Age field on the query. When I run it I get a parameter box open. Is it supposed to do that?
Also I looked at another tutorial and noticed that at the end of a similar , expression (I think thats what this is called?) that the parenthesis at the end were closed as such ())
Is there a reason for the above to be closed as ))). Sorry, I dont quite understand this?
Cheers
Ani
 
You should not have a Field named "AGE".

Place this in a new Field of the query on the very first line.

Age: DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB])))

Day does have () after it. It is just that there is some stuff in the middle.

I told you that you will be using Code within days.

PS

If you are stuck with the field Age then Change Age in the attached to myAge.
 
Struggling to work out how the expressions are written but think Im going to leave it for another day.
Ani
 
You should not have a Field named "AGE".

Place this in a new Field of the query on the very first line.

Age: DateDiff("yyyy",[DOB],Date())+(Date()<DateSerial(Year(Date()),Month([DOB]),Day([DOB])))

Day does have () after it. It is just that there is some stuff in the middle.

I told you that you will be using Code within days.

PS

If you are stuck with the field Age then Change Age in the attached to myAge.

OOOOOHHH! THanks Rain. Im getting confused with the way its written. But I think Im going to have to accept that it will take a while!
I dont like the parameter thing and I cant find a tutorial! Having one of those days where nothing makes sense, maybe I should go and brush my mare!
Thank you
Ani
 
There is a link in my Signature that contains some thing I have written.

Go there and download the one on Age. It should explain things better.
 
Is it the Public at SkyDrive? I dont have permission to open it or it has expired msg?
 
I am having problems with Shy Drive.

Here is an attachment.
 

Attachments

oh no, now I have a syntax comma error msg! Im giving up today.:banghead:
Ani:confused:
 
oh no, now I have a syntax comma error msg! Im giving up today.:banghead:
Ani:confused:

Thats because Im trying to add the tbl bit underneath age to the query! DOH. Im really not doing anything properly today.
Parameter thing has me confused so back to the help files!
:confused::(:o
 
Its "HrseDOB" so I changed the expression to HrseDOB from just DOB. Was that correct?

YES

It should work now with no parameters. There is more than one DOB in the expression. So change all of them.
 

Users who are viewing this thread

Back
Top Bottom