Automated addition of days in a duration field (1 Viewer)

aattas

Registered User.
Local time
Today, 05:27
Joined
Dec 24, 2014
Messages
74
Guys,
I have a field that calculates the expiry date once I entered the duration starting from the entry date as so:
Me.expirydate = date + duration

It's fine until I want to add 14 days to the duration if the expiry date is today. I tried as follows:
If me.expirydate=today then me.duration = [duration] + 14
Firts time it worked if I refreshed it. Then nothing happen.

Help & thanks
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:27
Joined
Aug 30, 2003
Messages
36,124
Try

If me.expirydate=Date() then me.duration = me.duration + 14
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:27
Joined
May 21, 2018
Messages
8,525
Then nothing happen.
In the vb window. Go to Tools, Option, Editor tab and select Require Variable Declaration. It will make your life easier.

The only way this would have done nothing without throwing an error would be because it thinks "today" is an undeclared variable. If variable declaration would have been required it would have thrown an error, the error would have been on the word Today, and it would have said "Sub or Function not defined" making it easy for you to debug.
Not declaring variables can mask a lot of issues.
 

aattas

Registered User.
Local time
Today, 05:27
Joined
Dec 24, 2014
Messages
74
Thanks man. I will try and let you know
Cheers
 

aattas

Registered User.
Local time
Today, 05:27
Joined
Dec 24, 2014
Messages
74
Hi . I tried the first choice and I did what u recommend. Now what. ? What I need to do for the duration change?

Thanks
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:27
Joined
Aug 30, 2003
Messages
36,124
I assume you're replying to MajP so I'll get out of the way.
 

aattas

Registered User.
Local time
Today, 05:27
Joined
Dec 24, 2014
Messages
74
Please it's the same system. If you can help I appreciate.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:27
Joined
Aug 30, 2003
Messages
36,124
I offered code; I have no idea if you've tried it and if so what the result was.
 

Users who are viewing this thread

Top Bottom