INF: Nz Function Returns Zero-Length String in Query (186310)
The information in this article applies to:
- Microsoft Access for Windows 95 7.0
- Microsoft Access 97
This article was previously published under Q186310 Novice: Requires knowledge of the user interface on single-user computers.
SYMPTOMS
In the versions of Microsoft Access listed at the beginning of this
article, if you use the Nz() function in a query expression on a Null value
in a number field, the Nz() function returns a zero-length string value and
not a zero as expected.
CAUSE
Microsoft Access Help for the Nz() function states that the second
argument, ValueIfNull, is optional and goes on to say:
If the value of the variant argument is Null, the Nz function returns
the number zero or a zero-length string, depending on whether the
context indicates the value should be a number or a string.
This is incorrect if you use the Nz() function in the manner stated in the
"Symptoms" section. A field with a data type of Number will be converted to
a string. As a result, a Null will return a zero-length string.
RESOLUTION
To return a string value of zero, use the optional second argument
ValueIfNull to specify the use of "0" in place of the Null.
REFERENCES
For more information about the Nz() function, search for "Nz," and then "Nz
Function" using the Microsoft Access Help Index.
Modification Type: | Major | Last Reviewed: | 10/20/2003 |
---|
Keywords: | kbdocerr kbprb KB186310 |
---|
|