In the database, the Invoice Date is defined as text and allow zero length = yes. And also I set the default to NULL too.
These are CONTRADICTORY. Allow zero length lets you put a "" - an
empty string - in the field. It LOOKS the same as a zero length string
but IT IS DIFFERENT.
At the time of creating the record, I move null and the code is "InvoicePrintedOn = Null".
Why?
When the record is created, the field contains NULL. It ALREADY
CONTAINS NULL. Setting it to NULL accomplishes nothing.
When I try to test if any un-printed invoices, I use DCount and the code is as following:
If 0 = DCount("[OrderNumber]", "qryOrder", "[InvoicePrintedOn] = Null") Then .....
The return result is always 0. That means all invoices have been printed which is not true.
Please advise what I have done wrong.
For one thing, you've ignored my previous message. As I said there,
the expression
[InvoicePrintedOn] = Null
has a value of NULL. It's not true; it's not false; it's NULL. The
effect is that it's treated as being false.
The correct expression would be
DCount("[OrderNumber]", "qryOrder", "[InvoicePrintedOn] IS Null")
The IS NULL operator (or its dual, IS NOT NULL) is the *only* way to
get a TRUE or FALSE result with NULL.