Conditional Formatting Syntax Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to set a fields color to yellow if the field isnull.

I am having problems with the syntax.

I have tried setting this to Field Value equal to isnull
and expression ""

Any help would be appreciated.

Thanks in advance.
 
Depends on which version of Access. More recent version include Conditional
Formatting as a Format option, no code required.
 
Access 2K allows me to add 3 conditions

What I am trying to say is if the value in a certian field is null then make
the backcolor of that field yellow else us the normal color for that field.

I believe I need to do this conditionally as this is a continious form and
displays variable records, each having a seperate condition.
 
Try this VBA code (works in access2000):

Put the code in some (event) sub where you want to check,
on save or forms load or whatever...


'Checks one field


If IsNull(fieldname) Then
fieldname.BackColor = vbYellow
else
fieldname.BackColor = vbWhite


OR


'This one checks all controls on form


Dim ctl As Object
For Each ctl In Me.Controls

If IsNull(ctl) Then
ctl.BackColor = vbYellow
else
ctl.BackColor = vbWhite
End If
Next





OR

'Checks all controls with a tag


Dim ctl As Object
For Each ctl In Me.Controls
If ctl.Tag = "Null" Then

If IsNull(ctl) Then
ctl.BackColor = vbYellow
else
ctl.BackColor = vbWhite
End If
Next
end if
 
Back
Top