locked
Validation rule 18+ RRS feed

  • Question

  • I am creating a database and i need the code/formula that stops people entering a D.O.B that is under the age of 18, i have checked online and the one i have already doesn't work. Can anybody help me with this problem? 
    Monday, May 11, 2015 1:29 PM

Answers

  • You can use this as the validation rule of a text box bound to the DOB field on a form:

    <=DateAdd("yyyy",-18,Date())

    This won't work for the validation rule of the field in the original table - it won't recognize functions such as Date or DateAdd.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by RunningManHD Monday, May 11, 2015 3:55 PM
    • Marked as answer by L.Hl Monday, May 18, 2015 2:40 PM
    Monday, May 11, 2015 2:19 PM
  • Hi,

    >>I am creating a database and i need the code/formula that stops people entering a D.O.B that is under the age of 18

    When design the database, you could add a validation rule and validation text for the DOB field.

    When you create a form based on the designed table, the rules for this field will apply to the control to hold BOD

    And also, you could apply a validation rule to a form control by adding a rule to the Validation Rule property and message text to the Validation Text property for this control.

    About how to add validation for Access data, you could refer to this article.

    Restrict data input by using validation rules

    Hope this could help you

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.Hl Monday, May 18, 2015 2:40 PM
    Tuesday, May 12, 2015 7:44 AM

All replies

  • You can use this as the validation rule of a text box bound to the DOB field on a form:

    <=DateAdd("yyyy",-18,Date())

    This won't work for the validation rule of the field in the original table - it won't recognize functions such as Date or DateAdd.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by RunningManHD Monday, May 11, 2015 3:55 PM
    • Marked as answer by L.Hl Monday, May 18, 2015 2:40 PM
    Monday, May 11, 2015 2:19 PM
  • Hi,

    >>I am creating a database and i need the code/formula that stops people entering a D.O.B that is under the age of 18

    When design the database, you could add a validation rule and validation text for the DOB field.

    When you create a form based on the designed table, the rules for this field will apply to the control to hold BOD

    And also, you could apply a validation rule to a form control by adding a rule to the Validation Rule property and message text to the Validation Text property for this control.

    About how to add validation for Access data, you could refer to this article.

    Restrict data input by using validation rules

    Hope this could help you

    Best Regards

    Lan


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.Hl Monday, May 18, 2015 2:40 PM
    Tuesday, May 12, 2015 7:44 AM