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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nz Assistance 1

Status
Not open for further replies.

kvest

Technical User
Jan 10, 2005
62
US
Hello,
I have reviewed the posts on this topic and believe it applies to my situation, but am lost on how to implement this. I have a report that displays and then totals (in the footer) the number of transactions by type. It counts them and sums them in two different boxes. The problem I am having is that a few of the transactions are very infrequent, so most often, there are none. The count function works fine, and shows 0 transactions. The sum, displays nothing, which then causes some of the other fields to not sum at all. My code on one of the infrequent transaction is:

=Sum(IIf([Type]='Report Sale',[Amount]))

How do I configure this with the nz to get it to return a 0?

Thanks in advance....
 
I think you need it on the amount:
=Sum(IIf([Type]='Report Sale',Nz([Amount])))
 
Remou, don't you have to add the default if the value is null. It could also be a string if you wish to show text.

=Sum(IIf([Type]='Report Sale',Nz([Amount][red], 0[/red])))
 
Thanks....

It was Sum(IIf([Type]='Report Sale',Nz([Amount]),0))
 
I was working off this:
Microsoft said:
valueifnull
[red]Optional[/red] (unless used in a query). A Variant that supplies a value to be returned if the variant argument is Null. This argument enables you to return a value other than zero or a zero-length string. If you use the Nz function in an expression in a query without using the valueifnull argument, the results will be empty in the fields that contain null values

If the value of the variant argument is Null, the Nz function returns the number zero or a zero-length string, 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.
 
Remou,
It is what I needed. When it didnt work, I remember the other posts I had read and tried adding the 0. Thanks alot....Now I understand how/where to use it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top