Add months to a date

  • Thread starter Thread starter Dan Lavish
  • Start date Start date
D

Dan Lavish

I am making a database for maintenance. I have three text boxes on a
form one is for the date serviced. Another is how often the unit is
serviced in months and the last one is the next service date. I need
code for a after update event on the date serviced that will add the
"frequency" (in months) to that date and insert it into the next
service date text box. I hope i made this clear. Thanks in advance!

Dan Lavish
 
Dan,
Given that you have the StartDate, and the Frequency, it's not necessary
to save the NextServiceDate. You can always recalculate NextServiceDate in
any subsequent form, query, or report.
In a calculated Text Control Control Source...
= DateAdd("m",[Frequency], [StartDate])

If you must save the NextServiceDate, bind a text control to the
NextServiceDate field in your table, and use the AfterUpdate event of BOTH
StartDate and Frequency...

NextServiceDate = DateAdd("m",[Frequency], [StartDate])
If either Start or Frequency cahnge, ServiceDate will be updated.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Dan,
    Given that you have the StartDate, and the Frequency, it's not necessary
to save the NextServiceDate.  You can always recalculate NextServiceDate in
any subsequent form, query, or report.
     In a calculated Text Control Control Source...
        = DateAdd("m",[Frequency], [StartDate])

    If you must save the NextServiceDate, bind a text control to the
NextServiceDate field in your table, and use the AfterUpdate event of BOTH
StartDate and Frequency...

NextServiceDate = DateAdd("m",[Frequency], [StartDate])
    If either Start or Frequency cahnge, ServiceDate will be updated.
--
    hth
    Al Campagna
    Microsoft Access MVP
   http://home.comcast.net/~cccsolutions/index.html

    "Find a job that you love... and you'll never work a day in your life."


I am making a database for maintenance. I have three text boxes on a
form one is for the date serviced. Another is how often the unit is
serviced in months and the last one is the next service date. I need
code for a after update event on the date serviced that will add the
"frequency" (in months) to that date and insert it into the next
service date text box. I hope i made this clear. Thanks in advance!
Dan Lavish

Hey thanks a lot I didn't think about making it a control thanks
Dan
 
Back
Top