Conditional Format Help

Pappy

Registered User.
Local time
Today, 09:58
Joined
Jun 12, 2003
Messages
28
I want to assign a different color to a date field, if that date equals the current date. I tried to use conditional formatting, and some VB code but can't get it to work. Any suggestions would be appreciated
 
pappy,

Good to see you back.

You can use the OnCurrent event for a form so
that whenever you move to a new record you can:

Code:
If Me.MyDate = Date Then
   Me.MyDate.ForeColor = 0
End If

0 = black
255 = red

You can experiment in design mode and when
you get a color that you want, cut and paste
the value in your code.

If they are entering the date, you can use the BeforeUpdate
event on your date field.

Hth,
Wayne
 
code...
If Me.Send_Notice150 = Me.Text33 Then
Me.Send_Notice150.ForeColor = 255
End If

where text33 equals a field which equals = now()

I tried .backcolor too but nothing changes on the form.

Thanks for the help guys

Pappy
 
pappy,

If your date is a SHORT date, compare it to DATE. otherwise
use NOW().

I think that your date is a short date and it will never have the
hours, minutes and seconds to make a match.

Wayne
 
If your date field was populated with the Now() function, it includes time also and so will never be equal to another date field. If you want to compare just the date parts, use the Format() function.

If Format(Me.Send_Notice150, "yyyymmdd") = Format(Me.Text33, "yyyymmdd") Then
 
Thanks to Pat that works great except now the field stays highlighted even if I go to the next record. How can I have it change back, if the date doesn't match
 

Users who are viewing this thread

Back
Top Bottom