Date Restrictions (1 Viewer)

Ltmac70

New member
Local time
Today, 00:32
Joined
Dec 7, 2016
Messages
9
I have a situation where I am entering data and a Date of birth is being entered. I want want to restrict the date so that someone who is between the ages of 9 and 12 can be entered.
I think that I need to enter the argument in the Validation Rule Field of the DOB column in the table. However being almost Brand new to Access and trying to learn this on my own I am unsure how to start the argument.

Help please
I want the value entered to be <current date-9years and > current date - 12 years
 

Ranman256

Well-known member
Local time
Today, 00:32
Joined
Apr 9, 2015
Messages
4,337
you dont have to put the restrtiction in the table. Id rather keep it on the form ,in case things change.
in the afterupdate of the date box, have it check..
Code:
sub txtBirth_afterupdate()
dim iYrs as integer

iYrs = DateDiff("yyyy",txtBirth,Date()) 
if iYrs >= 9 and iYrs <=12 then
 '  msgbox "ok"
else
   msgbox "ERROR, the age must be between 9 and 12"
endif
end sub
 

Ltmac70

New member
Local time
Today, 00:32
Joined
Dec 7, 2016
Messages
9
I did resolve this myself by putting in a validation rule
<DateAdd("yyyy",-9,Date()) and >DateAdd("yyyy",-12,Date())
and the a validation text "the applicant is not between the ages of 9 and 12"
 

Users who are viewing this thread

Top Bottom