Go Back   Access World Forums > Microsoft Access Discussion > Tables

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-23-2012, 07:22 AM   #1
Afrooman108
Newly Registered User
 
Join Date: Apr 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Afrooman108 is on a distinguished road
Exclamation Age validation rule 17-65

I need to use a validation rule that checks how old a person is by their date of birth.


Here is what i have so far, 6205 is the number days a 17 is alive, the difference in the date of birth must be more or equal to this, however it must be less that 23725 the number of days a 65 year old is alive.

6205<=DateDiff("d",[Date of Birth],[Employment Date]) And 23725>=DateDiff("d",[Date of Birth],[Employment Date])

Any help appreciated

Regards

Afrooman108 is offline   Reply With Quote
Old 04-23-2012, 07:42 AM   #2
Beetle
Duly Registered Boozer
 
Join Date: Apr 2011
Location: Camp Swampy (Denver, CO)
Posts: 1,806
Thanks: 13
Thanked 458 Times in 449 Posts
Beetle will become famous soon enough Beetle will become famous soon enough
Re: Age validation rule 17-65

Calculating age is a matter of determining the number of years since the Date Of Birth while taking into consideration whether or not their birthday has occurred yet in the current year. If it hasn't, then you subtract one. There are a lot of variations on this function. There are some examples here, here and here.
__________________
Sean Bailey

Dim Thirsty As String
Thirsty = "Insert Into Glass (Select Beer From Fridge)"
DoCmd.Execute Thirsty, dbPourAnotherOnError
Beetle is offline   Reply With Quote
Old 04-23-2012, 09:45 AM   #3
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,393
Thanks: 15
Thanked 1,623 Times in 1,541 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: Age validation rule 17-65

Validation rules are very limited in what they can do. DateDiff() is a VBA function and so it cannot be used in a validation rule. Remember Jet/ACE have a life of their own separate from Access. That means that table validation rules must be able to run without having Access even loaded on the computer. You will need to do the validation at the form level in the form's BeforeUpdate event and cancel the update if the date is invalid.
You can try just subtracting the two dates. It might work.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Tags
age , hoorah , stimulation , validation rule , verification

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
validation rule Bopsgtir General 4 01-03-2011 08:33 AM
Validation Rule geoffishere Forms 3 03-23-2010 02:31 PM
Validation Rule Help Sinclair General 18 04-06-2008 11:20 PM
validation rule for 1-10 desibasha General 2 03-12-2004 07:09 AM
Validation Rule HELP! summer Forms 4 08-09-2002 05:21 AM




All times are GMT -8. The time now is 11:55 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World