Conditional Formating for Empty Date Field

RexesOperator

Registered User.
Local time
Today, 18:53
Joined
Jul 15, 2006
Messages
604
I have taken a look around for this, but all I've found, so far, are examples for dates and date ranges. I want to use conditional formatting to change the background colour of a date field when no date has been entered.

How do I specify if the field data for a date field has no value? I have tried Null and 0, and a few other things, but I can't seem to get this to work.
 
It doesn't work on either Expression or Field Value.

This form is not used for entering data - just for displaying it.

I've even tried code:

Private Sub Form_Open(Cancel As Integer)
'BackColor field property changes to white when data is entered

If Not IsNull(txtDATESENT) Then
txtDATESENT.BackColor = 16777215
End If

End Sub
 
Make sure the back style property is not set on transparent. If it is, it won't matter what color you assign to it - it will never be seen.

-dK
 
Hmmm. Bit me before ...

I just tried the following ....

Code:
If Len(Nz(Me.txtControlName, "")) = 0 Then
    Me.txtControlName.BackColor = 255
End If

And it worked fine.

-dK
 
It doesn't work on either Expression or Field Value.

This form is not used for entering data - just for displaying it.

I've even tried code:

Private Sub Form_Open(Cancel As Integer)
'BackColor field property changes to white when data is entered

If Not IsNull(txtDATESENT) Then
txtDATESENT.BackColor = 16777215
End If

End Sub
The code you just supplied will not change the back color if the control is null. And you can't use that in a form's OPEN event because the recordset has not yet loaded. The Load event comes AFTER the Open event.

What is the exact expression you've used in the conditional formatting?
 
I now have the background colour set to white. I want the colour to change to yellow when there is no data. So I am trying

Field Value Is equal to "IsNull"

I tried dkinley's variation - that looks right, but what event would fire it?
 
I now have the background colour set to white. I want the colour to change to yellow when there is no data. So I am trying

Field Value Is equal to "IsNull"

I tried dkinley's variation - that looks right, but what event would fire it?

Actually, your Field value should be

Is Null

with the space and without quotes
 
That gives me a syntax error. With the quotes as in "Is Null" I don't get a syntax error or the expected result. I've attached a SnagIt image to show what I have.

I should this is on a continuous form.
 

Attachments

  • ConditionalFormatting.jpg
    ConditionalFormatting.jpg
    44 KB · Views: 681
Last edited:
That gives me a syntax error. With the quotes as in "Is Null" I don't get a syntax error or the expected result. I've attached a SnagIt image to show what I have.

I should this is on a continuous form.

now that I think about it, I think you can't use it in Field Expression because you can't test something to be equal to null.

So, change to expression Is and then

IsNull([YourFieldNameInBrackets])
 
So, change to expression Is and then

IsNull([YourFieldNameInBrackets])
Hi guys, I am trying to accomplish the same thing in my report: To highlight null valued fields. I used the advice you gave as quoted above, but the cells don't highlight unless the mouse is clicked on it.

Is there a different approach needed for Access 2007 to get the background to change upon load rather than onfocus?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom