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

need 0 when report has no data 1

Status
Not open for further replies.

dixxy12

Technical User
Jun 18, 2007
45
CA
Hi,

i have looked all over and can't seem to nail this down.

i am sure this is a very simple one.

i have a report with a sub report, text boxes in the foorter of the main report with this as control source
Code:
=IIf([rptContractExtraSub].[Report].[HasData],nz([rptContractExtraSub].[Report].[txtSumNet],0),0)
this is to check if data and sum the sub report.

then i have another box to sum the main report and add the value of the firsttext box with this
Code:
=nz(Sum([originalcontract]-([originalcontract]*0.08)),0)+[txtExtraNetTotal]
the problem i am having is what if the main report has no data then i get the #error in the textbox.

that is why i have tried the nz() in front of the formula, but it does not work.

is there a way of doing this?

thanks,

Sylvain
 
If there is a possibility that your main report has no data then you must reference its totals with IIf([HasData], , ). Nz() won't work if there are no records.

Try something like:
Code:
=IIf([HasData],Sum([originalcontract]-([originalcontract]*0.08))+[txtExtraNetTotal],0)


Duane
Hook'D on Access
MS Access MVP
 
That's what i was doing wrong!!!

thanks a million dhookom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top