conditional formatting with five conditions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the form displaying search results. One of the result fields is the
combo box which I would like to colour code depening on the result. At
present I am using conditional formating and I am highlighting just three
results with other two displaying identically. Is it possible to have the
background changed by five conditions ? How ?

Thanks for help.

Tony
 
Access is not capable of setting more conditions in Conditional Formatting.
However, you can do this in code. If the form isn't in continuous or
datasheet view, this should work fine. To do so, in the form's Current
event, you would use code similar to the following:

Select Case Me.txtMyTextbox
Case Is < 2
Me.txtMyTextbox.BackColor = vbRed
Case 3
Me.txtMyTextbox.BackColor = vbYellow
Case 4
Me.txtMyTextbox.BackColor = 4227327
Case Is > 10
Me.txtMyTextbox.BackColor = 12632256
Case Else
Me.txtMyTextbox.BackColor = vbWhite
End Select

You can add as many cases as you need. The numbers come from the numbers
that go into the Back Color property of the Properties dialog when you
select a color. You can also use the RGB() function for a value, if you
prefer.
 
Hi Wayne,

Thank you very much for your help, works perfectly. That is exactly what I
required.

Regards,

Tony
 
Back
Top