Lonnie's answer will work if you do not need the precise age, for instance,
if you don't need to know the clients age today - if his/her birthday is
next week, then you will get invalid information.  However, I did find this
function which calculates the person's age as of today.  I know that this is
probably a lot more code than you wanted to work with, but if you would put
it into a module, and then as the control source of your text box, put in
=AgeConvert([FieldNameWhichContainsDOB]) then you will get an accurate age
returned to you.

Function AgeConvert(varDOB As Variant, Optional varAsOf As Variant) As
Variant
On Error GoTo EH
'Purpose: Return the Age in years.
'Arguments: varDOB = Date Of Birth
'         varAsOf = the date to calculate the age at, or today if missing.
'Return:    Whole number of years.
Dim dtDOB As Date
Dim dtAsOf As Date
Dim dtBDay As Date 'Birthday in the year of calculation.

AgeConvert = Null         'Initialize to Null

'Validate parameters
If IsDate(varDOB) Then
    dtDOB = varDOB

    If Not IsDate(varAsOf) Then 'Date to calculate age from.
        dtAsOf = Date
    Else
        dtAsOf = varAsOf
    End If

    If dtAsOf >= dtDOB Then     'Calculate only if it's after person was
born.
        dtBDay = DateSerial(Year(dtAsOf), Month(dtDOB), Day(dtDOB))
        AgeConvert = DateDiff("yyyy", dtDOB, dtAsOf) + (dtBDay > dtAsOf)
    End If
End If
'Handle Errors Gracefully
Exit_EH:
    Exit Function

EH:
        MsgBox Err.Number & ": " & Err.Description
        Resume Exit_EH

End Function 

Dawn Crosier
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and questions to
the newsgroup so that others can learn as well.

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of spinlock9
Sent: Monday, October 16, 2006 5:44 PM
To: [email protected]
Subject: [ms_access] newbie

I do volunteer work for a small not-for-profit.  I know very little about
Access.  I put an Excel spreadsheet of client data into a table and am
working up a form.  One of the fields in the table is date-of- birth.  How
can I get a peson's age using that field into a form?  I have seen a formula
to do it, but have no idea how to get it into a form.

Thanks for any help.





 
Yahoo! Groups Links






--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.4/476 - Release Date: 10/14/2006




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ms_access/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ms_access/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to