I would like to create a field that calculates a date that is 39 months from a date I am entering on a form. Once I fill in a date in a field, I would like to have Access calculate the next field which would be 39 months later. What formula would I enter to achieve that effect? Thank you!
Help to calculate a time in the future
Collapse
X
-
Assuming the Text Box containing your Date is txtDate, and the New Date will be contained in txtNewDate, then in the AfterUpdate() Event of txtDate type the following code:Originally posted by neiljI would like to create a field that calculates a date that is 39 months from a date I am entering on a form. Once I fill in a date in a field, I would like to have Access calculate the next field which would be 39 months later. What formula would I enter to achieve that effect? Thank you!
Code:Private Sub txtDate_AfterUpdate() If Not IsDate(Me![txtDate]) Then Exit Sub Else Me![txtNewDate] = DateAdd("m", 39, Me![txtDate]) End If End Sub -
Thanks for your Help!Originally posted by ADeziiAssuming the Text Box containing your Date is txtDate, and the New Date will be contained in txtNewDate, then in the AfterUpdate() Event of txtDate type the following code:
Code:Private Sub txtDate_AfterUpdate() If Not IsDate(Me![txtDate]) Then Exit Sub Else Me![txtNewDate] = DateAdd("m", 39, Me![txtDate]) End If End SubComment
-
Originally posted by neiljI would like to create a field that calculates a date that is 39 months from a date I am entering on a form. Once I fill in a date in a field, I would like to have Access calculate the next field which would be 39 months later. What formula would I enter to achieve that effect? Thank you!
Use the dateadd(). In your query design view, click in the box where the field you want to calculate is and type
=DateAdd("m",+3 9, [the field name for the date entered])
once you click out of the box you will see
Expr1:=DateAdd( "m",+39, [the field name for the date entered])
Just change the word "Expr1:" to whatever you want the column name to be and there you go. Be sure there is a colon between your column name and the equal sign that starts the expression ... good luckComment
Comment