change form BG colour based on value

YouMust

Registered User.
Local time
Today, 05:40
Joined
May 4, 2016
Messages
106
Howdy,

I can change the text box background colour using conditional formatting.
However, I'd like the forms colour to change to red when a text field has a certain value (ie) 'fail'

Is that possible google hasnt return much hope!


Thanks in adavnce
YouMust
 
assuming your form is a single form then not with conditional formatting, but you can use some code

Code:
if mytextcontrol="fail" then 
    me.detail.backcolor=vbred
else
    me.detail.backcolor=vbwhite
end if
probably in your text control afterupdate event and perhaps the form current event

if it is a continuous form you can create an unbound text control sized to the detail section and set behind all the other controls, they apply conditional formatting to that.
 
ah perfect CJ many thanks!

Code:
Private Sub Form_Current()
If Result_2 = "Fail" Then
    Me.Detail.BackColor = 8421616
Else
    Me.Detail.BackColor = RGB(230, 237, 215)
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom