Conditional Formatting

J

Joe

How can I used conditional formatting on a form to display more than the
default 3 colors? I have a drop down with 5 conditions that requires a
different back color for each choice.

Thanks.

Joe
 
K

Klatuu

Use the After Update event of the combo box (drop down) to set the back color
depending on the selection using VBA.
Note. It may also be necessary to use the Form Current event to set the
color to the default.
 
J

Joe

Thanks, "Klatuu":

I used a code similar to the one you sent me however, I did not use the
Form Current event hence, I was still only getting the default choices. Here
is my code.

Here’s the code I used for changing the colors:

Me.Status.BackColor = IIf(IsNull(Me.Status.Value) = True, 15066597,
Switch(Me.Status.Value = "Green", 65280, Me.Status.Value = "Yellow", 65535,
Me.Status.Value = "Red", 255, Me.Status.Value = "Blue", 16737843,
Me.Status.Value = "Grey", 15066597))

please evaluate or add.

Thanks.

Joe
 
L

Linq Adams via AccessMonster.com

Also note that unless the form is a Single View form, all comboboxes on all
records
be formatted the same.
 
K

Klatuu

Linq has a good point, Joe. If this is a continuous or datasheet form, it
isn't going to work. Although you see several of the same combo box
controls, they are actually only one when it comes to their properties, So if
you change the back color on one, you are changing the back color on all.

Otherwise, here is a change to your expression to avoid the IIf statement:

Me.Status.BackColor = Nz( Switch(Me.Status.Value = "Green", 65280,
Me.Status.Value = "Yellow", 65535, Me.Status.Value = "Red", 255,
Me.Status.Value = "Blue", 16737843, Me.Status.Value = "Grey", 15066597),
15066597)
 
Top