Field background colour change on date?

  • Thread starter Thread starter tpdttjr6
  • Start date Start date
T

tpdttjr6

Guest
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
 
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
 
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.
 
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?
 
Just a shot here, but instead of RGB(#,#,#) how about just using "vbRed"?
 
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 ?
 
Providing it's not a datasheet put it on the forms current property, in the after update of the date field put Form_Current
 

Users who are viewing this thread

Back
Top Bottom