Conditional format a Null Date

  • Thread starter Thread starter Barry A&P
  • Start date Start date
B

Barry A&P

Conditional formatting doesnt seem to work for a null date.

I want a DateCompleted control to turn red if there is a Null date.

maybe something like
on current ifnull.date Backcolor = VBred ???

new to VB and cant seem to get anything to work
Any Ideas appreciated..
 
Conditional formatting will work, but has to be on the basis of an expression
not the value of the field. This is because Null is not a value, but the
absence of a value so nothing can = Null, not even Null. The result is
always Null. However, the IsNull function can be used in an expression.

In the conditional formatting dialogue for the control in question use:

Expression is……….IsNull([YourDateField])

or alternatively:

Expression is……….[YourDateField] Is Null

The square brackets around the field name are essential. If you omit them
the field name will be treated as a literal string, so the IsNull function
will never evaluate to True.

BTW if you've called your field Date I'd strongly recommend you change it to
something more specific such as TransactionDate, AppointmentDate or whatever
suits. Date is the name of a built in function so is best avoided for object
names.

It would be possible to do it in code in the form's Current event procedure,
but only if the form is in single form view as, in continuous form view the
colour of the control in every row would change. Conditional formatting
works in single form, continuous form or datasheet view.

Ken Sheridan
Stafford, England
 
Back
Top