>Somebody told me once how to make cells in a grid that have changed be a different color, but I cannot find where I wrote that down.
>
>This is what I tried:
>
>
>FOR i = 1 TO THIS.columncount
> THIS.COLUMNS[i].dynamicforecolor = ;
> "IIF CURVAL(EVAL(THIS.controlsource)) <> OLDVAL(EVAL(THIS.controlsource)), ;
> RGB(255,0,0), RGB(0,0,0))"
>ENDFOR
>
>
>
>I also tried it without the EVAL, and with an & instead. It doesn't give an error; it just doesn't work.
>
>As I'm typing this, I just got a clue. I'm using a view, so the controlsource is a field in the view, not the table. Is that why?
>
>How do I make this work with a view?
>
>Thanks,
>
>-Michelle
Hi Michelle,
If you got that during a UT chat then that "somebody" might be me. Original code is :
for ix = 1 to this.columncount
with this.columns(ix)
cField = substr(.controlsource,rat(".",.controlsource)+1)
cAlias = substr(.controlsource,1,rat(".",.controlsource)-1)
.DynamicBackColor = "iif(oldval([" + ;
cField+"],["+cAlias+"])#"+;
.controlsource+;
" or recno(["+cAlias+"])<0,"+;
str(rgb(255,0,0))+","+str(this.backcolor)+")"
endwith
endfor
I prefer this style vs setall (just preference and this one works all the time). Payoff is some local variables and a loop, but just done once in init, so I don't think it could be thought as a performance penalty.
Caution : Assumes nulls are not accepted, otherwise oldval() # val comparison generates error and should be extended to control with isnull().
PS : With the addition of a timer + custom property (blinkon) you could even make the color "blink".
And another extension could be made oldval() vs curval() for potential update conflict coloring.
Cetin