Using MS Access/2-digit year conundrum

Advertisement


Question
Hi Scott,

I have a date field with input mask 99/99/00;_ - (format dd/mm/yy-Australian) so users can type 130865 and I can then work out an age from that date.   The problem lies with the 2029 calendar setting ( I think it's .Net 4.5 setting) which I have read about but have no idea how to change.   So, if I type 140830 (14/8/1930) I get age 84.   If however I type in 140829, it returns 14/8/2029, and age -15!

Can you suggest a snippet of code to reverse this trend, so that it converts the date to 1929 and age to 85?

thanks in anticipation
Pete

Answer
If Me.datecontrol>Date Then
   Me.datecontrol = DateAdd("yyyy",-100,Me.datecontrol)
End If

Since this is a date of birth, the assumption is that the date will be earlier than today. So if it is, it will just subtract 100 years to get the correct date.

Hope this helps,
Scott<>

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.