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!

Divide by zero error, my brain hurts!

Status
Not open for further replies.

millrat

Technical User
Dec 23, 2003
98
US
Hi all,

I am having some trouble trying to figure this one out.

Report field: [txtTonnnes], Total tonnes in a day.
SubReport Field (in footer): [txtTotal], Total downtime in minutes.

The following will calculate tonnes/hr for a day

=([txtTonnes]/(1440-Reports!rptShiftReport!rptSubTotalDowntime!txtTotal))*60

My problem is if there is no downtime I get a divide by zero error!

I've tried the IIf() statement but I can't get it right.

Does any one have a solution?
Cheers,
millrat
 
'My problem is if there is no downtime I get a divide by zero error!'

Pardon?
If there is NO downtime you are dividing by 1440, so that is not the cause of the problem.
You will only get a divide by zero error if the total downtime is 1440.

However the syntax is not correct here.
From the main report you need:
rptSubTotalDowntime.Report!txtTotal
The 'Reports!rptShiftReport' bit is not necessary in this context.

If the total downtime CAN be 1440 then what do you want the answer to be in that situation?



 
lupins46,
That's probably why my brain hurts. I don't have one!!
Yes you're right. But have also highlighted the other problem.

So for 1440 min downtime the answer would be 0 t/hr and for 0 min the answer would be [txtTonnes]/24hours t/hr.

I still can't figure out why I'm getting an error for 0 mins. Shouldn't it be [txtTonnes]/24 ?

millrat
 
I think you need:

=iif(nz(rptSubTotalDowntime.Report!txtTotal,0)=1440, 0,([txtTonnes]/(1440-rptSubTotalDowntime.Report!txtTotal))*60)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top