chuckster
03-07-2001, 02:39 PM
I have to two calculated fields in text boxs on a form which add up a list of prices. One is for returns the other is for items resent. A third field subtracts [Returned amount] from [sent amount] I want an event that will make the back colour or text colour of a third field change to red if the field is negative.
Any ideas?
llkhoutx
03-07-2001, 05:57 PM
On currentfield AfterUpdate
if me!currentfield , 0 then
me!otherfield.backcolor = (specify a number)
end if
oncurrent event
me!otherfield.backcolor = white (or whatevercolo)
use the color pallettee to set the color of a textbox and utilize that backcolor value (number) as the background color.
deekras
03-07-2001, 06:46 PM
this works for me!
with balance being the field name
If (Me!balance) < 0 Then
Me!balance.ForeColor = 255
Else
Me!balance.ForeColor = 0
End If
chuckster
03-07-2001, 07:37 PM
Thank for your replies but still no cigar for me. Absolutely nothing happens. i put the code in an afterupdate event
Does it matter that I'm refering to text boxes? The Field [Text189] has a control source
[text164]-[text165]. Both Text 164 and text165 are additions of other fields as well. Does this matter?
code I'm using
if me.text189 <0 then me.text189.forcolour = 255
And about 10 variations of. using brackets and !.
Luke
deekras
03-08-2001, 07:34 AM
i have it on the onformat of the section that the fields are in.
You don't need vb to do this for a currency field just set the format for the control to
$#,##0.00[Black];$#,##0.00[Red]or $#,##0.00[Black];-$#,##0.00[Red]or $#,##0.00[Black];($#,##0.00)[Red]choose which on suits best.
HTH
chuckster
03-08-2001, 01:36 PM
Thanks for thatn Rich. I can use that it about five other places now. Cheers.
llkhoutx
03-08-2001, 01:39 PM
Use the expression builder to build what you want, it's almost 100% accurate.