Home  Fees/Services  Access 2010 Template  Access Tutorial  Access Download  Articles  Search  Contact  Privacy  Links

Visual Basic Age Calculation Methods
Calculate Person's Age Using VBA

Visual Basic Tutorials:
Access-Google Earth
Age Calculation
Change To Proper Case
Email via Gmail #1
Send Gmail Email #2
Inactivity Logout Code
Outlook Email
Read Email Access
Email Attachment
Send Outlook Email
Running Sum
Denormalize Records
Stock Quotes
Find Database Path
Detail-Master Update
Data Field Validation
Field Value New-Old
Access Version
Global Variable Parameter
Global Variables
Active Labels
Files List Box
Mail Merge
Quick Sort
Recordset Filters
Reference Form Field
Select Case
Access Transactions

Visual Basic Function Examples

Age Calculation in Access

Age Calculation examples are illustrated below.  The first method used the datediff function in the age calculations. The second tutorial demonstrates the use of the date serial function.  Each example uses today's date - this can be easily switch to a field from you forms or tables.

Microsoft Access is a fully capable database and it's primary limitations is the number of concurrent users it will support. Generally, we recommend a limit of 10 to 15 users.

We create databases large and small. Some of our databases help run entire small businesses. We also handle unique businesses such as flyrod manufacturing, cheese making, marina management, and cable tv inventory.

Age Calculation Long Method

Private Sub Birth_Dte_AfterUpdate()
    Dim iyears As Integer
    Dim tmonth As Integer
    Dim Bmonth As Integer
    iyears = DateDiff("yyyy", "01/01/" & DatePart("yyyy", Me.Birth_Dte), _
    "01/01/" & DatePart("yyyy", Me.Todays_Date)) - 1

    tmonth = DatePart("m", Me.Todays_Date)
    Bmonth = DatePart("m", Me.Birth_Dte)
    Select Case tmonth
        Case Is > Bmonth
            iyears = iyears + 1
        Case Is = Bmonth
            If DatePart("d", Me.Birth_Dte) <= _
            DatePart("d", Me.Todays_Date) Then iyears = iyears + 1
    End Select
End Sub

VBA Age Calculation - Short Method Using Date Serial Visual Basic Function:

Function age(vb_Dte As Variant)
  Dim v_Age_Calc As Variant
  v_Age_Calc = DateDiff("yyyy", vb_Dte, Now)
  If Date < DateSerial(Year(Now), _
    Month(vB_Date), Day(vb_Dte)) Then v_Age_Calc = v_Age_Calc - 1
  age = CInt(v_Age_Calc)
End Function

Additional information on the Date Serial function can be found in a VBA Functions tutorial section.  You can also review details about the DateDiff function in the same section.

Blue Claw Database Design Downloadable Tutorial:
Running Sum Query Method  

A Blue Claw Software Design Template:

Airline Reservations Database Template

A Blue Claw Database Design Article:

Learn How To Select A Consultant

Microsoft Office:
MS Access 2000 Through 2016 and Office 365 & Sharepoint

Contact Information

Copyright 2000-2018 Blue Claw Database Design

Microsoft Access 2007, 2010, 2013 & 2016