Update field - how to calulate a new date (1 Viewer)

jd_boss_hogg

Registered User.
Local time
Today, 09:15
Joined
Aug 5, 2009
Messages
88
Hi All - can somebody give me advice on calculating a date field please ?

I have a form with "due date" (format: medium date). When i click in another field, i want this value to update, calculated by today's date.

So my calculation needs to be

Newduedate = (today date - due date) +due date

Example, original due date was Feb 10th..... i click on the "update" field on Feb 15th. I now want new due date to be 20th Feb (so "today" + 5 days)

What calculations can i do ? I cant seem to do calculations on dates?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:15
Joined
May 7, 2009
Messages
19,243
if you are using Form, you can use AfterUpdate event of DueDate textbox.
Code:
Private Sub DueDate_AfterUpdate()
dim var as variant
var=nz(Me!DueDate.OldValue, 0)
if var<>0 then
    Me![DueDate] = DateDiff("d", var, Me.DueDate) + Me.DueDate
End If
End Sub
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 08:15
Joined
Feb 19, 2013
Messages
16,612
Dates are stored as numbers so just add and subtract as required

your calculation doesn’t make sense to me - so if today is 10 days after the due date- you want to add 10 days? And if today is 10 days before the due date, you want to deduct 10 days?
 

plog

Banishment Pending
Local time
Today, 02:15
Joined
May 11, 2011
Messages
11,646
Code:
Newduedate = (today date - due date) +due date

Click here to learn about an algebraic cancellation trick mathematicians don't want you to know about.
 

Users who are viewing this thread

Top Bottom