Northwind Question

Wapug

Registered User.
Local time
Today, 05:47
Joined
Apr 14, 2017
Messages
51
On the product details form in the Northwind database there is a "Go to Product" box that has the coding below as its row source. I cant make out what the <>Nz function is doing here. Could someone please explain this?
SELECT [ID], [Product Code], [Product Name], [List Price] FROM Products WHERE [ID]<>Nz(Form![ID],0) ORDER BY [Product Code];
 
Nz() is the only creature that can eat a null without dying. In this SQL, if Form!ID is null, the Nz() function keeps things alive by returning a zero instead.

To test how this would fail without Nz(), remove the Nz() function from the SQL, and then navigate to a new record in Form (which would likely cause Form!ID to be null) and observe the result. That failure is what the Nz(), in this case, prevents.

hth
Mark
 

Users who are viewing this thread

Back
Top Bottom