Backcolor thru Case Select

S

Secret Squirrel

I have a continuous form that I want to change a backcolor on a specific
field based on its value. I'm using the following case select but it's not
working correctly. It's defaulting every "Vdate" field for all my records to
the first case in my code. Why is that? Also, should this code be going
behind the Current Event of my form?

Select Case Me!VDate
Case "R"
Me!VDate.BackColor = 16744703
Case "N"
Me!VDate.BackColor = 8454016
Case "U"
Me!VDate.BackColor = 16776960
Case "A"
Me!VDate.BackColor = 8454143
Case Else
Me!VDate.BackColor = -2147483643
End Select
 
D

Dirk Goldgar

Secret Squirrel said:
I have a continuous form that I want to change a backcolor on a specific
field based on its value. I'm using the following case select but it's not
working correctly. It's defaulting every "Vdate" field for all my records
to
the first case in my code. Why is that? Also, should this code be going
behind the Current Event of my form?

Select Case Me!VDate
Case "R"
Me!VDate.BackColor = 16744703
Case "N"
Me!VDate.BackColor = 8454016
Case "U"
Me!VDate.BackColor = 16776960
Case "A"
Me!VDate.BackColor = 8454143
Case Else
Me!VDate.BackColor = -2147483643
End Select


Unfortunately, you won't be able to do that. On a continuous form, there's
really only one of each control, just painted multiple times. For that
reason, when you change any of the control's attributes except its bound
value, that change applies to all copies of the control. You could do what
you want with conditional formatting, which *is* applied on a row-by-row
basis, but that allows no more than three special format conditions per
control, and you have four.
 
S

Secret Squirrel

Well actually I can use conditional formatting even though I have 4 options.
There is always one of those 4 in the field "VDate". I can use one as the
default and then add 3 more conditional formats. That makes 4. Thanks for the
idea!!!
 

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