Date Validation RRS feed

  • Question

  • I Have a timesheets form, on the main form it has a period end date. Then in the subform it has the individual day details. I would like code that gives an error if a date over 14 older is entered.

    Eg: Period End Date: Nov 24, 2018 so any date entered in the subform Nov 11, 2018 or older will have a popup error message.

    Thank you

    Thursday, November 29, 2018 3:52 PM

All replies

  • Hi,

    For data validation, you can use the BeforeUpdate event. In this case, use the BeforeUpdate event of the control where they enter the date and maybe use something like:

    If Me.DateEnteredControlName<=DateAdd("d",-14,Me.Parent.PeriodEndDateControlName) Then
         MsgBox "Date is too old.", vbInformation, "Not Allowed"
    End If

    Hope it helps...

    Thursday, November 29, 2018 4:37 PM