Calculate date based on another form control RRS feed

  • Question

  • This should be simple and if Access Help was of any use it would be.

    I have a form based on a table which includes a date/time field.

    On this form I need to display another unbound control next to the date control that shows another date which is two years beyond the other date.

    I tried putting in the Default property the following but it did not work:


    I will also need to perform this operation in several queries and am assuming I would use the same syntax there.

    Wednesday, March 23, 2016 3:13 PM


  • Set the Control Source of the text box to


    Or if you need the user to be able to edit the date, use the After Update event of the OriginalDate text box:

    Private Sub OriginalDate_AfterUpdate()
        If IsNull(Me.FutureDate) And Not IsNull(Me.OriginalDate) Then
            Me.FutureDate = DateAdd("yyyy", 2, Me.OriginalDate)
        End If
    End Sub

    where FutureDate is the text box to be set to the date 2 years after that in OriginalDate.

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

    Wednesday, March 23, 2016 3:53 PM