Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

MS Access adding dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jim Bob - 26 Dec 2005 02:45 GMT
Hi,
Does anyone know how to make 1 date field 6 months ahead of another in
ms access?
Eg, I have a field called "startdate" where a date is entered. I want
"offprobationdat" equal to startdate + 3 months.
Thanks a lot.
Wayne Gillespie - 26 Dec 2005 02:52 GMT
>Hi,
>Does anyone know how to make 1 date field 6 months ahead of another in
[quoted text clipped - 4 lines]
>
>*** Sent via Developersdex http://www.developersdex.com ***

Sub StartDate_AfterUpdate()

If Not IsNull(Me.StartDate) Then
    Me.OffProbationDate = DateAdd("m",3,Me.Startdate)
Else
    Me.OffProbationDate = Null
End If

End Sub

Wayne Gillespie
Gosford NSW Australia
jim Bob - 26 Dec 2005 04:55 GMT
Hi Wayne,
Thanks a lot for the reply.
How do i USE this code?
Eg do i put it as a macro or module or paste the code into the table in
Design view?

Cheers
Wayne Gillespie - 26 Dec 2005 07:13 GMT
>Hi Wayne,
>Thanks a lot for the reply.
[quoted text clipped - 5 lines]
>
>*** Sent via Developersdex http://www.developersdex.com ***

You need to enter the data in a Form in order to make this work. Entering the data directly into a table will not
trigger the calculation.

Create a form which includes StartDate, OffProbationDate and any other fields you require from your table. You can use
the Form Wizard to create this form if you want.

Once you have the form, open it in design view and click on the StartDate control and open it's properties sheet. (right
click - properties).

Click on the Event tab and select AfterUpdate. Click the (...) button which appears at the right of the property. Select
Event Procedure. The form's code module will open with the header and footer for the procedure auto created as such -

Sub StartDate_AfterUpdate()

End Sub

Paste the following code between the header and footer lines -

If Not IsNull(Me.StartDate) Then
    Me.OffProbationDate = DateAdd("m",3,Me.Startdate)
Else
    Me.OffProbationDate = Null
End If

Open the form in normal mode. When you enter a date in StartDate, OffProbationDate will be set to 3 months ahead of the
StartDate. If StartDate is deleted OffProbationDate will also be deleted.

Wayne Gillespie
Gosford NSW Australia
Chris2 - 26 Dec 2005 18:05 GMT
> Hi,
> Does anyone know how to make 1 date field 6 months ahead of another in
[quoted text clipped - 4 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***

jib Bob,

UPDATE UnknownTable
  SET offprobationdat = DateAdd("m", 3, startdate)

Sincerely,

Chris O.
jim Bob - 27 Dec 2005 04:19 GMT
Hi Guys,
Thanks a lot for your help!!
I've sorted it out via a form and an update query.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.