Conditional Format (4 Viewers)

Jonny45wakey

Member
Local time
Today, 19:34
Joined
May 4, 2020
Messages
48
Hi I have a textbox on a form called OEEMTDMTand it contains a percentage value eg 91.6%

I'd like the texbox backcolour to change to Green if >=92% or red if <92% but both conditional formatting tool and vba conditional formatting not working.

The textbox on the form has its backcolour set to normal not transparent also.

I've used the following vba but in the form on load event but not working

If Me.OEEMTDT.Value >= "92" Then
Me.OEEMTDT.BackColor = vbGreen
Else
Me.OEEMTDT.BackColor = vbRed
End If

Any ideas please on whats wrong here, is it the wrong vba, the wrong event trigger please?

Thanks

Jonny
 
It will likely be .92?
Debug.print the value. Ignore the format.
It will also be a number, NOT a string. :(
I would probably use the current event, as the Load runs once, (clue is in the name?), so what happens when you move to another record?

Edit: Could also just use Conditional Formatting, then the event will not matter.
 
Last edited:
first of all your comparison is between Numeric and String, so that will not work.
second, it will only work for Single Record form.
and probably move the code on the Current event.
 
Last edited:

Users who are viewing this thread

  • Back
    Top Bottom