Free Lessons Courses Seminars TechHelp Fast Tips Templates Topic Index Forum ABCD

 Home   Courses   Seminars   Templates   TechHelp   Forums   Help   Contact   Join   Order   Logon More... What's New? Popular Links ------------ Access Courses Access Index Access TechHelp Access Forum ------------ Excel Courses Excel Index ------------ Code Vault Testimonials

 Access    Excel    Word    Windows    HTML

# NZ

## Using the NZ Function

In this tutorial you will learn how to use the NZ Function.

The NZ function can be used to return zero, a zero-length string (" "), or another specified value when a Variant is Null.

=NZ( value, valueIfNull )

value
valueIfNull

Take an example Table of Customers.

CustomerT
CustomerIDFirstNameLastNamePhoneCustomerSinceCreditLimitDaysGraceIsActive
1RichardRost716555777701/01/201210011True
2JoeSmith716555343401/03/19905005True
3SuzanJones562436514602/01/199815002False
4AlanWatson419389121217/05/2012503True
5AnnaPicore71323647905/05/200510204True
6RonaldSimms780746546804/04/1992502True
7DonaldBarker416441555501/03/19982505True
8BennySperduti716726726206/04/199916007False
9PeteSmith564559777704/04/20005003False
10BarbraPeters829282728831/12/2005501True
11JoeJones549546546601/06/20045003True
14PezzDispo26/09/201204True
16BobSmith04/10/201209True

If we wanted to check if there was a Phone number for Pezz we could.

tblNames
CustomerIDFirstNameLastNamePhoneCustomerSinceCreditLimitDaysGraceIsActive
14PezzDispo26/09/201204True

The result is "".

Query

The results using a Query would be

```	SELECT NZ([Phone], "") FROM tblNames;
```

FORM

In a Form you could set the Default Value of a Textbox to

```	=NZ([Phone], "")
```
VBA

In a Form add a TEXTBOX control and rename it "txtNZ", then you could add the following in the Load Event.

```	Private Sub Form_Load()
txtNZ = NZ([Phone], "")
End Sub
```

Courses Search

 Check out these other pages that may be of interest to you:
 5/31/2023 Calculator 7 5/30/2023 DoEvents 5/26/2023 Hide With Macro 5/25/2023 Calculator 6 5/24/2023 Object Size Analyzer 5/24/2023 Calculator 5 5/23/2023 Plural 5/22/2023 Calculator 4 5/19/2023 Calculator 3 5/18/2023 Calculator 2