Forum Discussion
Using Nz. Is =0 necessary?
- Aug 28, 2022Nz([Expr1], [Expr2]) function, simly means:
If the Value in [Expr1] is Null then Substitute [Expr2] as Return value, otherwise return the Value of [Expr1].
If you omit [Expr2] then the Default (which is a Null String "") will be returned.
This expression returns a boolean -- true or false
Nz([Amount],0)=0
What that means, in words, is this. If the value of Amount is Null, use 0, but if the value of Amount is not Null (i.e. it is a value which could include 0 because 0 itself is not null). Compare that result to 0.
If 0 = 0 then the result is true, otherwise it is false
Nz([Amount],0) returns a non-null value that could be any possible value from your Amount field, including 0 because, again 0 is not null.
In one case, then the answer is "True" or "False"
In the other case, the answer is any non-null number. e.g 1, 10,000, 22, -234, or 0
Does that help?
- Tony2021Aug 28, 2022Iron Contributorthanks George.
One follow up:
<Nz([Amount],0) returns a non-null value that could be any possible value from your Amount field, including 0 because, again 0 is not null.
==>in the case of Null then it would return 0, correct?- arnel_gpAug 28, 2022Iron ContributorNz([Expr1], [Expr2]) function, simly means:
If the Value in [Expr1] is Null then Substitute [Expr2] as Return value, otherwise return the Value of [Expr1].
If you omit [Expr2] then the Default (which is a Null String "") will be returned.- George_HepworthAug 28, 2022Silver Contributor
If the value of the variant argument is Null, the Nz function returns the number zero or a zero-length string (always returns a zero-length string when used in a query expression), depending on whether the context indicates the value should be a number or a string. If the optional valueifnull argument is included, then the Nz function will return the value specified by that argument if the variant argument is Null. When used in a query expression, the NZ function should always include the valueifnull argument,
If the value of variant isn't Null, then the Nz function returns the value of variant.