conditional

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I want to highlight a date, so that when six months has elapsed the date
would go red or any other colour.
Any help would be appreciated, any actual wording of what I need to enter in
the conditional formatting would also be helpful.
Thanks
 
Hi,

this is just a suggestion it may not be what you are looking for.

There is a datediff function that tells you the number of days elapsed
between two dates. which you could make an iif statement to see if the
diference between the date in your data and the current date(date()) is
greater than 90 days. But i am unsure how to do this for exact months....
 
Ok the datediff function will also return the difference between two dates
in mmonths, so ignore what I said before, i dont use this function that often.
Your statement should look something like this:

iif(DateDiff("m",yourdatefield ,Now()) > 3, txtTextbox.forecolor = vbred,
txtTextbox.forecolor = vbblack)

something along those lines should work sorry but I didn't have time to test
this.....

Hope it helps !
 
if I get time tomorrow I will try this, many thanks for the help, I can do it
in Excel but Access is a bit harder.
Many thanks again
 
Tamiyra said:
Ok the datediff function will also return the difference between two dates
in mmonths, so ignore what I said before, i dont use this function that often.
Your statement should look something like this:

iif(DateDiff("m",yourdatefield ,Now()) > 3, txtTextbox.forecolor = vbred,
txtTextbox.forecolor = vbblack)


The logic is close, but you can not use statements in an
IIf, only expressions.

Use code in the text box section's Format event procedure:

If DateDiff("d", yourdatefield, Date()) > 182 Then
txtTextbox.ForeColor = vbRed
Else
txtTextbox.ForeColor = vbBlack
End If

Using "m" in DateDiff only tells you how many month
boundaries have passed. which could be only 120 or so days.

Another way to approach this is to use Conditional
Formatting (Format menu).
 
Back
Top