need to return Null in date field

  • Thread starter Thread starter vicki.wells
  • Start date Start date
V

vicki.wells

I'm working on a calculated field in a query in which I'm using an IIf
statement to return either the date from another field or Null,
depending on whether a Yes/No field is checked. It works except that
when the checkbox is checked I need it to return a blank in the date
field, and I'm getting #error. I'm using " " as the value to return if
the Yes/No is checked. Do I need to do it differently for a date field?
 
Vicki,
Try...
YourDateFieldName = Null

Your " " is entering a Space in the date field, which is not allowed...
 
A null is not the same as a space or zero-length string.

Specify that you want Null, e.g.:
=IIf([MyYesNo] = True, Null, Date())

If JET still does not understand the field as a date, wrap the expression in
CVDate(), e.g.:
=CVDate(IIf([MyYesNo] = True, Null, Date()))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top