Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Place a zero when dlookup has no results 1

Status
Not open for further replies.

MICKI0220

IS-IT--Management
Jul 20, 2004
337
0
0
US
I have a field on a report that references a query. if the query produces an empty results list, I get a null value in my field. How do I set this property to place a zero in this field if the value of dlookup is null?

Code:
=dlookup('comm', 'qryInvoices')

Thank you for you assistance in this quandry.
 
in Access, the Nz function lets you return a value when a variant is null.
The syntax for the Nz function is:
Nz ( variant, [ value_if_null ] )
variant is a variable that is a variant datatype.
value_if_null is optional. It is the value to use when the variant is a null value. If this parameter is omitted and the variant is a null value, the Nz function will return a zero or a zero-length string.
For Example:
Nz (varName, "n/a")
The example above would return the value 'n/a' if the variable varName contained a null value.
Nz (varName)
The example above would return a zero-length string if the variable varName contained a null value.
VBA Code:
The Nz function can be used in VBA code. For example:
Dim LOption As String
LOption = Nz(varChoice, "Not Found")
in this example, the variable called LOption would now contain value in the varChoice variable unless it was a null value. If the varChoice variable contains a null value, the Nz function will return "Not Found".
=nz(dlookup('comm', 'qryInvoices'),0)
 
that's what I was missing. I tried it the nz infront, but did not have the ,0 at the end. That did it.
Thank you
 
Not sure why because if you do not provide a second argument it should default to 0
value_if_null is optional. It is the value to use when the variant is a null value. If this parameter is omitted and the variant is a null value, the Nz function will return a zero or a zero-length string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top