Field formatting

  • Thread starter EddiesVoicebox via AccessMonster.com
  • Start date
E

EddiesVoicebox via AccessMonster.com

Hi All,
I am trying desperately to create a report that will highlight missing data.
currently i have the report built but just want to change the colour of the
fields when they are empty.
After much trawling the net i found the code below. I just cant get it to
work. I only want the empty cells changed and it is changing the entire
column to white (not red). Any advice woudl be most welcome.
Regards
EddiesVoicebox

Private Sub detail_format(cancel As Integer, formatcount As Integer)
Dim bgred As Long, bgwhite As Long
bgred = RGB(255, 0, 0)
bgwhite = RGB(255, 255, 255)

If Me.Payroll_Number.Value = Null Then
Me.Payroll_Number.BackColor = bgred
Else
Me.Payroll_Number.BackColor = bgwhite
End If

If Me.Line_Manager.Value = Null Then
Me.Line_Manager.BackColor = bgred
Else
Me.Line_Manager.BackColor = bgwhite
End If

End Sub
 
D

Duane Hookom

You can't use "= Null" since Null never equals anything. You can try:
If IsNull(Me.Payroll_Number.Value) Then
Me.Payroll_Number.BackColor = bgred
Else
Me.Payroll_Number.BackColor = bgwhite
End If

This code assumes your control name is Payroll_Number and that the field is
actually Null and not a zero-length-string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top