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

IIF and NZ

Status
Not open for further replies.

dixxy12

Technical User
Jun 18, 2007
45
CA
Hi,

I am trying to return a "0" when not data is available and having trouble doing so.

Here is what i am working with in the control source of the unbound text feild:
Code:
=IIf(IsNull([qreCommitedMat]![SumOfQtsOptimized]),"0",[qreCommitedMat]![SumOfQtsOptimized])

it works where there is data, but gives me the famous #error when there is no data.

What do i have wrong?

Thanks
 
How are ya dixxy12 . . .

Try this:
Code:
[blue]=Nz([qreCommitedMat]![SumOfQtsOptimized],0)[/blue]


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 



Hi,

Also, BIG diffeence between a "0" and 0.

I would assume, that [SumOfQtsOptimized] is NUMERIC and not STRING. Can't mix them!

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
dixxy12 . . .

My post didn't work either?

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Check if SumOfQtsOptimized by itself is returning the #Error.

 
i think i need to put either an iif or nz in the query feild so that the query does the work not the text feild...but not sure what syntax to use to acheive this....
 
What about replacing this:
=IIf(IsNull([qreCommitedMat]![SumOfQtsOptimized]),"0",[qreCommitedMat]![SumOfQtsOptimized])
with this ?
=Nz("SumOfQtsOptimized","qreCommitedMat",0)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
that in the text feild's control source gives me a:
'The expression you entered has a function containing the wrong number of arguments.' error.
 
OOps, sorry for the typo:
=Nz(DLookUp("SumOfQtsOptimized","qreCommitedMat"),0)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Code:
SELECT Sum(IIf([QtsOptimized],[QtsOptimized],"0")) AS qts, tblInventoryCommited.Done, tblInventoryCommited.ItemNumber
FROM tblInventoryCommited
GROUP BY tblInventoryCommited.Done, tblInventoryCommited.ItemNumber
HAVING (((tblInventoryCommited.Done)=False) AND ((tblInventoryCommited.ItemNumber)=[Forms]![frmPurchaseOrders]![frmTabs].[Form]![ItemNumber]));
 
So, there is no SumOfQtsOptimized field in qreCommitedMat ...
 
yes...i would like it to give ma a 0 (zero) when no data is available
 

You do not have a field called SumOfQtsOptimized in your query, so you CANNOT use it in calculating the value of a text box.

Try replacing SumOfQtsOptimized with qts, which is the alias you used in your query - Sum(IIf([QtsOptimized],[QtsOptimized],"0")) AS qts


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top