View Full Version : Field background colour change on date?


tpdttjr6
11-10-2000, 05:19 AM
I have a form on which one of the fields returns a date, I want the background colour to change to red when the date is 7 older than the present date. I have tried the following code in the forms OnCurrent property but it doesnt seem to work.

Sub Form_Current ()
If LastOfLastOfDate.Value > Date - 7 Then
LastOfLastOfDate.BackColor = RGB(255, 0, 0)
LastOfLastOfDate.FontWeight = "700"
Else
LastOfLastOfDate.BackColor = RGB(255, 255, 255)
LastOfLastOfDate.FontWeight = "400"
End If


End Sub

Can any body see what I'm doing wrong
i'm Using Access 2.0

rjohnstone1
11-10-2000, 06:10 AM
Click on the field on your form.
Click Format -> conditional formatting
and enter an expression and set the formatting of the cell for the condition.
It is a good tool to use

tpdttjr6
11-11-2000, 03:08 AM
Thanks for that tip but as I'm using Version 2.0 there is no conditional formatting available, must only be later versions of access that you can use it.

Richie
11-11-2000, 09:14 AM
Something like
If Me.LastOfLastOfDate >= Date-7 Then
Me.LastOfLastOfDate.BackColour = RGB(255, 0, 0)
Me.LastOfLastOfDate.FontWeight = "700"
etc.
Is that really the name of your field?

CurtisFehr
11-12-2000, 08:30 AM
Just a shot here, but instead of RGB(#,#,#) how about just using "vbRed"?

tpdttjr6
11-18-2000, 02:24 AM
No neither of these seams to work, am I putting the code in the right place ie Form Properties, On Current?? or does it need to go in one of the Field properties ?

Richie
11-18-2000, 05:55 AM
Providing it's not a datasheet put it on the forms current property, in the after update of the date field put Form_Current