Hello,
I'm trying to change the background color of a cell called Year FL based on the value in it. I can't use conditional formatting because I have more than 3 conditions (Access 2007). I've set the back style to be normal and I'm using VBA code. This is my code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case [Year FL]
Case Is > 2000
[Year FL].BackColor = 52479 'orange
Case Is > 5000
[Year FL].BackColor = 255 'red
Case Is < -2000
[Year FL].BackColor = 52479
Case Is < -5000
[Year FL].BackColor = 255
End Select
End Sub
*Sorry I'm new here. Not sure how to format code for the forums.
Anyway, the gist of it is that if the value in the cell is greater than $5000 or less than ($5,000), the background will be red. If the value is between 2,000 and 5,000 (or -2,000 and -5,000), the background is orange. Otherwise it is white. However, my code from above is not working the way I want it to. The format of the cell itself is currency with no decimal places and negative numbers are within parentheses. Thank you for any help.
I'm trying to change the background color of a cell called Year FL based on the value in it. I can't use conditional formatting because I have more than 3 conditions (Access 2007). I've set the back style to be normal and I'm using VBA code. This is my code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case [Year FL]
Case Is > 2000
[Year FL].BackColor = 52479 'orange
Case Is > 5000
[Year FL].BackColor = 255 'red
Case Is < -2000
[Year FL].BackColor = 52479
Case Is < -5000
[Year FL].BackColor = 255
End Select
End Sub
*Sorry I'm new here. Not sure how to format code for the forums.
Anyway, the gist of it is that if the value in the cell is greater than $5000 or less than ($5,000), the background will be red. If the value is between 2,000 and 5,000 (or -2,000 and -5,000), the background is orange. Otherwise it is white. However, my code from above is not working the way I want it to. The format of the cell itself is currency with no decimal places and negative numbers are within parentheses. Thank you for any help.