Alerting dates more than X many days old

Sara Overton

Registered User.
Local time
Today, 09:27
Joined
May 22, 2001
Messages
34
I've set up coding to recognise a date.

What I need to do is alert the user if the date is older than 35 days or more.

It then asks the user to input another date (input box with a declared variable), if this is stil 35 days or more then it won't let them go any further.

The problem I've got is it only alerts if 35 days, if 36 it doesn't do anything.

The relevant section of code reads:

Dim strinput As String
Dim strinput2 As Date

If [Invoice_Date] < DateAdd("d", -35, Date) Then
strinput2 = InputBox("This invoice is more than 35 days old, what date is stamped on the invoice?")
If strinput2 < DateAdd("d", -35, Date) Then..............


Any ideas where I'm going wrong? I think it may be the code:
< DateAdd("d", -35, Date)
 
sara,

both of these will do what you want...

If [Invoice_Date] > (Date-35) then...

or

If DateDiff("d",[InvoiceDate],Date())>=35 then ...

Hope that helps

axa
 
Hi Sara,

I tried your procedure, and it works just like it should. Your problem may be further down where you won't let them continue if it is more than 35 days old. So your "If strinput2 < DateAdd("d", -35, Date) Then...." line tells it if it is less than 35 days (i.e. 36 or greater) then do something. I think if you change the < in that statement to <= you will find that the 35 days won't work either. This should lead you to the incorrect statement.

HTH
Robert
 

Users who are viewing this thread

Back
Top Bottom