Conditional Formatting vs Code

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 :)
 
A

ant1983

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
 
R

ryguy7272

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top