Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link 2 dates, if I enter one date the other appears 1

Status
Not open for further replies.

Husameddin

Technical User
Mar 4, 2003
17
GB
I want to create a form of bus maintenance record, and this record must indicate clearly the date of the last and next service inspection, I have table of the maintenance schedules and I know for example that bus A must be serviced once every month, so I want when I put the date of the last service (which I know) the date of next service come up.
the user doesn’t know when the bus must be serviced what he has to do is entering the date of the last maintenance which he knows and the form will tell him when the next service must be.
If there is anther way to do this without using vba codes can you tell me please. I am using ms office xp

example: bus A

date of last service date of next service
1/2/2003 1/3/2003


 
Try:

Me![date of next service] = DateAdd("m", 12, Me![date of last service])

Use your actual Control names
 
Or more correctly 1 instead of 12:

Me![date of next service] = DateAdd("m", 1, Me![date of last service])

Use your actual Control names
 
It would be nice if you could let me Know if my suggestion worked. I looked at your Personal Profile and you've been into Tek-Tips after my suggestion.
 
Thank you for your reply
To be honest I tried to do it but I wasn’t sure where to put it, should i put in event of the (date of next service) in Before Update or On Enter
I am new to Access as you see thank you for your help Billpower i appreciate your help and i will be happy if you showed me where to put code.
thank you
 
Dear husameddin

Put the above into the After Update event of the control [date of last service]

To do this, Open your Form in Design View, Double-click on the control [date of next service], a Window should pop-up, Caption similar to this Text Box: date of next service. Make sure the "All" or "Event" Tab is selected, scroll down until you see "After Update", click anywhere in the box to the right of it. Click on the button to the far right with 3 dots on it (...). This will open the Visual Basic Editor. Add the following (blue text)

Private Sub date_of_last_service_AfterUpdate()
Me![date of next service] = DateAdd("m", 1, Me![date of last service])
End Sub
 
Thank you very very much Billpower I worked with me ;o)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top