• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 113
  • Last Modified:

Change font color on a form field

Why isn't this working?  I have it in the oncurrent event of a form

    If Me.txtActualHours.Value > Me.txtSchedHours.Value Then
        Me.txtHrVariance.ForeColor = vbRed
        Else
        Me.txtHrVariance.ForeColor = vbBlack
    End If

Open in new window

0
SteveL13
Asked:
SteveL13
  • 3
  • 2
  • 2
1 Solution
 
PatHartmanCommented:
Looks OK to me.  Do you have any compile errors?  Put a stop in the code on line 1 and then check the values in all the fields.
0
 
Rey Obrero (Capricorn1)Commented:
is the current event of your form firing?
0
 
Rey Obrero (Capricorn1)Commented:
what are the other codes in the current event of the form?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
SteveL13Author Commented:
Compiled fine.  Also did compact and repair for kicks.

First of all I removed .Value because when I hovered over I got type mismatch.
After putting a stop on line 1 and hover over fields I get:
Me.txtHrVariance.ForeColor = 0 on lines 1, 2, and 4

Yes, I believe the current event is firing

No other code in the current event.
0
 
SteveL13Author Commented:
Example db attached.

Need to somehow...

If Me.txtActualHours.Value > Me.txtSchedHours.Value Then
        Me.txtHrVariance.ForeColor = vbRed
        Else
        Me.txtHrVariance.ForeColor = vbBlack
    End If
Test-DB.zip
0
 
PatHartmanCommented:
The problem is that you are doing this in a form in data sheet view (continuous won't work either).  You need to use conditional formatting.Conditional Formatting
0
 
SteveL13Author Commented:
Yep again.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now