Conditional Formatting for Blank Date Field Not Working (1 Viewer)

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
Hi,

I have a report which is based on a query that includes the following expression named "PreInstallationInspectionDate" (I know it's a long name)

Code:
DLookUp("[PreInspectionDate]","tblWorkOrder","CandidateID=" & [CandidateID])

In the report, I would like the PreInstallationInspectionDate field highlighted if the field is blank. I've tried using IsNull([PreInstallationInspectionDate]), Nz([PreInstallationInspectionDate]) and both IsNull and Nz with the Dlookup formula used in the query but nothing is working.

Any suggestions?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:18
Joined
Oct 29, 2018
Messages
21,491
Is PreInspectionDate a Date/Time field? Does it have a Default Value?
 

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
Is PreInspectionDate a Date/Time field? Does it have a Default Value?
It is a Date/Time field with no default value
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:18
Joined
Oct 29, 2018
Messages
21,491
If you use Nz() in your expression, what happens?
Code:
Nz(DLookup(...), "")
Then, in your Conditional Formatting, try to use:

Value Is: ""
 

SHANEMAC51

Active member
Local time
Tomorrow, 01:18
Joined
Jan 28, 2022
Messages
310
I have a report which is based on a query that includes the following expression named "PreInstallationInspectionDate" (I know it's a long name)
I prefer pre_installation_inspection_date-much more readable and without spaces, otherwise square brackets will be needed
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:18
Joined
Sep 21, 2011
Messages
14,350
Why not check for Len() > 0 ?
 

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
If you use Nz() in your expression, what happens?
Code:
Nz(DLookup(...), "")
Then, in your Conditional Formatting, try to use:

Value Is: ""

Not getting the conditional formatting to work with the Nz or with the suggestion of Nz(Dlookup(...),"")
 

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
I prefer pre_installation_inspection_date-much more readable and without spaces, otherwise square brackets will be needed
Thanks. I couldn't find a shorter description for that field. I will try your suggestion.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:18
Joined
Sep 21, 2011
Messages
14,350
Thanks. I couldn't find a shorter description for that field. I will try your suggestion.
You do know that fields have captions?, that can describe a field better on forms/reports?
If that was my DB the field would be called something along the lines of PreInstallInspDate or even shorter. :) and the caption Pre Installation Inspect Date.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:18
Joined
Sep 21, 2011
Messages
14,350
I am not familiar with this one. Would I type Len([PreInstallationInspectionDate])>0?
Yes, or whatever the control name is.
Most people rename the control slightly to differentiate between field and control, like txtPreInstallationInspectionDate, making it even longer. :)
 

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
Yes, or whatever the control name is.
Most people rename the control slightly to differentiate between field and control, like txtPreInstallationInspectionDate, making it even longer. :)
That didn't work either :(
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:18
Joined
Oct 29, 2018
Messages
21,491
If you use Nz() in your expression, what happens?


Not getting the conditional formatting to work with the Nz or with the suggestion of Nz(Dlookup(...),"")
Hi. Can you post a sample db with test data to demonstrate the problem?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:18
Joined
Oct 29, 2018
Messages
21,491
Is this what you mean?

Edit: File attachment deleted per OP's request.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:18
Joined
Feb 19, 2002
Messages
43,346
Value Is: ""

"" is NOT the same as Null. "" is a Zero Length STRING and isn't even valid for dates which are numeric.

I used my own db for this sample so the date name is different from yours.

ConditionalFormattingIsNullJPG.JPG
 
Last edited:

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
Yes! That's what I need to highlight! So it's the order of the expression - [PreInstallationInspectionDate] Is Null

As always, thank you so much for your help 😃
 

Tophan

Registered User.
Local time
Today, 18:18
Joined
Mar 27, 2011
Messages
367
I'm going to delete the DB from the forum. I really appreciate everyone's help on this.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:18
Joined
Oct 29, 2018
Messages
21,491
Yes! That's what I need to highlight! So it's the order of the expression - [PreInstallationInspectionDate] Is Null

As always, thank you so much for your help 😃
That's just one way to do it. I figured if I could avoid using a function, then why not?

Good luck with your project.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:18
Joined
Oct 29, 2018
Messages
21,491
I'm going to delete the DB from the forum. I really appreciate everyone's help on this.
Would you like me to delete the db in my post as well?
 

Users who are viewing this thread

Top Bottom