Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Question Unanswered: How to auot work out date

    I want to create a database / form where a date is inserted, can I have a couple of other fields automatically update with a date of say the date entered + 1 month ?

    I'm pretty new to database's so dont have a clue - Cheers

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Sure, this code adds one month to the first day entered and assigns it to the second date field. To modify this to, say two months, change the 1 to a 2.
    Private Sub txtFirstDate_AfterUpdate()
     If Not IsNull(Me.txtFirstDate) Then
      Me.txtSecondDate = DateAdd("m", 1, Me.txtFirstDate)
      Me.txtSecondDate = Null
     End If
    End Sub
    Since you're new to database design, I should tell you that in most cases a calculated field, like the data in txtSecondDate, shouldn't be stored in a table, but rather simply re-calculated, like it is here, whenever you need it.
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts