Age validation

Rhymeo

New member
Local time
Today, 08:27
Joined
Sep 19, 2006
Messages
3
Hello!

I'm really new to Access and need help with a validation rule

Right, i have a 'Date of Birth' field and what would the validation rule be if i only want people over the age of 12 to be able to go any further?

I've tried various other rules found online but some just don't work...

Any help would be great!

Thanks
 
I saw an example of that in this forum just a day or so ago. Do a search in the forum.
 
This is if you are filling out a form and want to stop it there. Put it on the Form's Before Update event.

Code:
Dim intAge As Integer
intAge = DateDiff("yyyy", CDate(Me.txtDOB), Date)

If intAge < 12 Then
MsgBox "Sorry, this person is not 12, or older.", vbExclamation, "Under Age"

Cancel = True
Me.Undo

End If
 
Right, i'll try that now

I've searched the forums but they generally concern other stuff related to ages, not helping too much
 
If you wish to account for the birthday this year then use:
Code:
intAge = DateDiff("yyyy", DOB, Date) + (Date < DateSerial(Year(Date), Month(DOB), Day(DOB)))
 

Users who are viewing this thread

Back
Top Bottom