Solved Error 13 - Type mismatch when trying to change text box color (1 Viewer)

PatAccess

Registered User.
Local time
Today, 11:58
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
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:58
Joined
Jan 23, 2006
Messages
15,380
I don't think vbBack is a color, but that may not be your issue.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:58
Joined
Jul 9, 2003
Messages
16,285
Code:
Me.SupplyCateg.ForeColor = vbBack

Should be:-
Code:
Me.SupplyCateg.ForeColor = vbBlack
 

PatAccess

Registered User.
Local time
Today, 11:58
Joined
May 24, 2017
Messages
284
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?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:58
Joined
Jul 9, 2003
Messages
16,285
the text box value is not changing color when the form loads. Any idea?
Check the settings of your control. You may have it set to "Transparent". If that's the case it won't show the colour.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:58
Joined
Feb 19, 2013
Messages
16,627
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!)
 

PatAccess

Registered User.
Local time
Today, 11:58
Joined
May 24, 2017
Messages
284
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
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:58
Joined
Feb 19, 2013
Messages
16,627
In that case use conditional formatting
 

Users who are viewing this thread

Top Bottom