Calculating age from a DOB field

J

John

I've created a Word 2003 template/form and have a field for DOB and Age. I'd
like the age in rounded years (no months or decimals needed) to calculate
based on today's date referencing the DOB field (i.e. age to calcualte when
the DOB is entered). I suspect this will require VBA but I'm a novice at
this and could use some help. Can anyone tell me how to make this happen,
please?
 
J

John

Doug's link provided someting that Ithink is way more complicated than what
I'm tryingto do. to clarify: I have a Date of Birth field and immediately
after that a filed for age. Rather than having to calcualte age in my head
while I'm completing a form I'd like to have the age calculate automatically
based on today's date compared to the Date of Birth field. This is pretty
easy in Excel but I'm baffled about how to do this in a form field in a Word
Template.
 
J

John

Doug's solution is way too complicated for me. Is thre an easier method to
do what I'm tryingto do? It's pretty easy in Excel but I'm stumpped about
how to do this in a Word Templeate form field.
 
D

Doug Robbins - Word MVP

Assuming that you are using FormFields in a document that is protected for
forms and that the bookmark name DOB is assigned to the formfield into which
the date of birth is to be inserted and the bookmark name of Age is assigned
to the formfield in which the age is to be displayed, running a macro
containing the following code on exit from the DOB formfield will populate
the Age formfield with the age in years.

With ActiveDocument
If IsDate(.FormFields("DOB").result) Then
.FormFields("Age").result = DateDiff("yyyy",
..FormFields("DOB").result, Date)
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top