Conditional Formatting - almost working but not quite.

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?
 
G

Guest

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.
 
R

Rick B

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.
 

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