Age Calculations

J

John Whitney

RYATES,

Here's something you could try...

Begin by adding this function to a module:

Public Function GetAge(DateofBirth As Date) As String
Dim dblTotalDays As Double, dblRemainderDays As Double
Dim intTotalYears As Integer
dblTotalDays = DateDiff("y", CDate(CStr(DateofBirth)
& " 12:00 AM"), Now())
intTotalYears = Int(dblTotalDays / 365)
dblRemainderDays = dblTotalDays - (intTotalYears *
365)
GetAge = intTotalYears & " Years " & dblRemainderDays
& " Days"
End Function

Add a new UNBOUND texbox to your report. The control
source of this field should be:
=GetDate([DateOfBirth])

In this example, I am referencing a field called
[DateofBirth]. Replace this field with the field in your
database which stores the person's Birth Date.

Hope this helps,
John Whitney
 

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

Similar Threads


Top