Nz Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Use this method to return zero, a zero-length string (" "), or another specified value when a value is Null. For example, you can use this function to convert a Null value to another value and prevent it from propagating through an expression. Returns a Variant.

expression.Nz(Value, ValueIfNull)

expression   Required. An expression that returns a DataSourceControl object.

Value  Required Variant. The value to convert.

ValueIfNull  Optional Variant. Value to return if the Value argument argument is Null. This argument enables you to return a value other than zero or a zero-length string.

Remarks

This method is useful for expressions that may include Null values. To force an expression to evaluate to a non-Null value even when it contains a Null value, use the this method to return a zero, a zero-length string, or a custom return value.

For example, the expression 2 + varX will always return a Null value when the VariantvarX is Null. However, 2 + MSODSC.Nz(varX) returns 2.

In the next example, the optional argument supplied to the Nz method provides the string to be returned if varFreight is Null.

  varResult = MSODSC.Nz(varFreight, "No Freight Charge")