I have this expression:
=Iif(max( Fields!xpto.Value)=0,"--",1/max( Fields!xpto.Value))
My problem is there when Fields!xpto.Value) is 0 then give me the
folling error:
"The value expression for the textbox 'textbox36' contains an error:
Attempted to divide by zero."
and appear #Error in the report. How can I solve this problem?
Best Regards,
PedroI usually like to put a function in the Report level (Report
properties-->Code tab) code to handle divide by zero. It looks something
like this:
Public Function CalcAvg(dblNum As Double, dblDen As Double) as Object
if (dblDen = nothing) or (dblDen = 0)
CalcAvg = 0
else
CalcAvg = dblNum / dblDen
end if
End Function
From within my report, I call it like this
=Code.CalcAvg(Fields!field1.value, Fields!field2.value)
Hope this helps
Andy Potter
blog : http://sqlreportingservices.spaces.live.com
info@.(NOSPAM)lakeclaireenterprises.com
<pedro.geraldes@.netvisao.pt> wrote in message
news:1175601733.774876.255550@.p15g2000hsd.googlegroups.com...
>I have this expression:
> =Iif(max( Fields!xpto.Value)=0,"--",1/max( Fields!xpto.Value))
> My problem is there when Fields!xpto.Value) is 0 then give me the
> folling error:
> "The value expression for the textbox 'textbox36' contains an error:
> Attempted to divide by zero."
> and appear #Error in the report. How can I solve this problem?
> Best Regards,
> Pedro
>|||Works fine.
Thanks!
On Apr 3, 2:29 pm, "Andy Potter" <i...@.lakeclaireenterprises.com>
wrote:
> I usually like to put a function in the Report level (Report
> properties-->Code tab) code to handle divide by zero. It looks something
> like this:
> Public Function CalcAvg(dblNum As Double, dblDen As Double) as Object
> if (dblDen = nothing) or (dblDen = 0)
> CalcAvg = 0
> else
> CalcAvg = dblNum / dblDen
> end if
> End Function
> From within my report, I call it like this
> =Code.CalcAvg(Fields!field1.value, Fields!field2.value)
> Hope this helps
> --
> Andy Potter
> blog :http://sqlreportingservices.spaces.live.com
> info@.(NOSPAM)lakeclaireenterprises.com<pedro.geral...@.netvisao.pt> wrote in message
> news:1175601733.774876.255550@.p15g2000hsd.googlegroups.com...
>
> >I have this expression:
> > =Iif(max( Fields!xpto.Value)=0,"--",1/max( Fields!xpto.Value))
> > My problem is there when Fields!xpto.Value) is 0 then give me the
> > folling error:
> > "The value expression for the textbox 'textbox36' contains an error:
> > Attempted to divide by zero."
> > and appear #Error in the report. How can I solve this problem?
> > Best Regards,
> > Pedro- Hide quoted text -
> - Show quoted text -
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment