Add months to a 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
 
A

Al Campagna

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."
 
D

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."


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top