Solved Error 13 - Type mismatch when trying to change text box color

PatAccess

Registered User.
Local time
Today, 16:38
Joined
May 24, 2017
Messages
284
Hello.
Any idea why I would be getting error 13: Type mismatch in this block of code?
Code:
Private Sub Form_Load()

    If Me.MaxQt.Value > Me.MinQt.Value Then
        Me.SupplyCateg.ForeColor = vbRed
    Else
        Me.SupplyCateg.ForeColor = vbBack
    End If
End Sub
 
I don't think vbBack is a color, but that may not be your issue.
 
Code:
Me.SupplyCateg.ForeColor = vbBack

Should be:-
Code:
Me.SupplyCateg.ForeColor = vbBlack
 
I don't think vbBack is a color, but that may not be your issue.
oops yes that fixed the error issue but I the text box value is not changing color when the form loads. Any idea?
 
the text box value is not changing color when the form loads

needs a bit more explaining - what is the default colour? if black and MaxQt <=MinQt it will remain black. Note you do not need Me. or .Value as these are the defaults - saves a bit of typing and makes your code easier to read.

In any event the data is loaded in the load event but a record is not current to test values, try the form current event. Note your code won't work in a continuous form - use conditional formatting

@Uncle Gizmo - transparency applied to the back colour, not the fore colour (bet you saw back!)
 
needs a bit more explaining - what is the default colour? if black and MaxQt <=MinQt it will remain black. Note you do not need Me. or .Value as these are the defaults - saves a bit of typing and makes your code easier to read.

In any event the data is loaded in the load event but a record is not current to test values, try the form current event. Note your code won't work in a continuous form - use conditional formatting

@Uncle Gizmo - transparency applied to the back colour, not the fore colour (bet you saw back!)
I am using continuous form so that won't work. Thank you
 
In that case use conditional formatting
 

Users who are viewing this thread

Back
Top Bottom