Conditional Formatting - almost working but not quite.

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

Guest

Hi guys,

I am working a on telephone log system. I have a combo box called Priority
and I want to make it so that if the option "High Priority" Is selected, all
the text fields have a background colour of red.

This works when the priority is changed to High Priority from one of the
other options, but if you scroll through the records and find one with a high
priority the colour doesn't actually change until the priority combo is
changed to one of the other values and then back again.

My code is:

Private Sub Priority_Level_AfterUpdate()
If Me.[Priority Level] = "Highly Urgent" Then
Me!Message.BackColor = vbRed

Else
Me!Message.BackColor = vbWhite
End If
End Sub

How can I get this to check the value in the Priority Level combo box as
soon as you open the form?
 
Try putting the code you posted in the On Current event of the form. Your
code only executes after you have updated the control. The On Current event
will fire each time your move to a new record.
 
Why use code at all? Just use conditional formatting. It is built in on
the Format menu. Changing the fist drop-down box will allow you to enter an
"expression" so you can base a control's format on another control or
condition.
 
Back
Top