A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional format a Null Date



 
 
Thread Tools Display Modes
  #1  
Old October 13th, 2008, 12:08 AM posted to microsoft.public.access.tablesdbdesign
Barry A&P[_2_]
external usenet poster
 
Posts: 119
Default Conditional format a Null Date

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..
  #2  
Old October 13th, 2008, 12:31 AM posted to microsoft.public.access.tablesdbdesign
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default Conditional format a Null Date

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

"Barry A&P" wrote:

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..


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.