Cahnge Field colour on contents

K

Kahuna

Hi Folks - this seems bizarre in the extreme.

I have an unbound field on a form where in the 'Current' event I am trying
to change the back-colour dependant upon the contents. Here's the code:

'Set CC Box Colour
Me![cc_value].BackColor = 16777215

Select Case [cc_value].Value

Case 1
Me![cc_value].BackColor = 255
Case 2
Me![cc_value].BackColor = 4227327
Case 3
Me![cc_value].BackColor = 65280
Case 4
Me![cc_value].BackColor = 65535
Case 5
Me![cc_value].BackColor = 16776960
Case 6
Me![cc_value].BackColor = 16776960
End Select

The effect is that the colour changes appear to lag behind as I cursor
through the records on this form. i.e. contents '1' appears red, and on
cursoring to a contents '5' for example - it remains red until I come across
a different contents. Going back to the '5' plays it in its correct colour.

I tried Me.Refresh and Me.Repaint both in the 'Current' even to no avail!
Should this be running in a different event?

Any comments or advice appreciated.

Cheers
 
K

Kahuna

Sorry Guys - coding was out of synch with the field population calculation.
Re-ordered the code and its fine.

Cheers
 
S

Stefan Hoffmann

hi,
The effect is that the colour changes appear to lag behind as I cursor
through the records on this form. i.e. contents '1' appears red, and on
cursoring to a contents '5' for example - it remains red until I come across
a different contents. Going back to the '5' plays it in its correct colour.
I assume you are using an endless form: this cannot work.

Use conditional formatting or take a look at lebans.com, he has a
solution for this problem.


mfG
--> stefan <--
 

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