Conditional Formatting vs Code

  • Thread starter Thread starter ant1983
  • Start date Start date
A

ant1983

Hi,

I have a report that runs off a query - one of my fields is
numPercentageBooked.

I was going to use conditional formatting to change the backcolour of the
cell as per the below:

0% to 65% = Red
66% to 99% = Yellow
100% = Green
More that 100% = Blue

I noticed though that i cant do more than 3 conditions so that wouldnt work.
Besides, it didnt work even if i just did the 3 conditions so not sure what
i did wrong.

So im guessing my alternative is to write some code and put that on the Load
Event.

I have no idea what to write. Please help :)
 
I wouldnt know how to apply that code plus how do i know what numbers the
colours are?

Ive adjusted as follows but didnt expect it to work (it didnt btw - LOL):

Private Sub Report_Load()
If PercentageBooked Is <=0.65 Then
PercentageBooked.BackColor = 4259584
Else
PercentageBooked.BackColor = -2147483643
End If
End Sub
 
Try something like this:
In your form open event you'll need something like....

Select Case Me.[Field Work]
Case "Red"
Me.YourObjectName.BackColor = 255
Case "Yellow"
Me.YourObjectName.BackColor = 123456
Case "Blue"
Me.YourObjectName.BackColor = 123456
Case "Green"
Me.YourObjectName.BackColor = 123456
End Select
Me.Repaint

Or, send me an email and I'll send you a sample DB that I have.
(e-mail address removed)
 
Back
Top