Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Manipulating Field Background Colors on a Form 2

Status
Not open for further replies.
Feb 6, 2003
48
0
0
US
Good Morning-

I want to be able to program a form on my database to flag blank fields by making them yellow. I have added the following code to the "On Current" event of the form properties:

Code:
Private Sub Form_Current()

    With Form_frmMissing
        
        If IsNull(Me.STEP.Value) = True Then
            Me.STEP.BackColor = vbYellow
        Else
            Me.STEP.BackColor = vbWhite
        End If
    
    End With

End Sub

It works to a point... If the field is blank, it will indeed change the color to yellow, but once the field is yellow, it doesn't change back to white when a value is present in the field. Thanks in advance for any help.
 

That's probably because you are not putting a NULL value into the field. You are putting an EMPTY value in.
Try this...
Code:
If Me.STEP = "" Then


Randy
 
If STEP is Null, it isn't the same as "".

If this is a continous form, it won't work.

You are not use the "With" in your code:
Code:
Private Sub Form_Current()
    [s]With Form_frmMissing[/s]
        If Me.STEP & "" = "" Then
            Me.STEP.BackColor = vbYellow
        Else
            Me.STEP.BackColor = vbWhite
        End If
    [s]End With[/s]
End Sub
I'm not sure why you don't just use Conditional Formatting and get rid of the code.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top