If negative change Colour

chuckster

Registered User.
Local time
Today, 19:38
Joined
Oct 4, 2000
Messages
52
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?
 
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.
 
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
 
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
 
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
 
Thanks for thatn Rich. I can use that it about five other places now. Cheers.
 
Use the expression builder to build what you want, it's almost 100% accurate.
 

Users who are viewing this thread

Back
Top Bottom