Division by zero

I am working on an Open Order Margin Report I have a text box with the SourcExpr property set to “Unit Cost”/“Unit Price” I am getting an error message that says “Divsion by zero 0/0”. I have some items where the unit cost or unit price is 0.****, could this be the cause of the error and if so what can I do to get around this problem? unit cost and unit price are decimal fields.

Hi Stephen, In your code just put this syntax and you should be all set. If “Unit price” <> 0 then := “Unit cost” / “unit price”; Thanks Best regards Suresh.

…aditionally you’ll have to define a new variable, e.g. %Margin, assign this variable to your text box (in SourceExpr) and put the above code in the OnAfterGetRecord of the Sales line… To be sure that the %Margin of the previous line will not be repeated in a line where “unit price” = 0 add the following code to Suresh’s example: IF "Unit price" <> 0 THEN "%Margin" := "Unit cost" / "unit price" ELSE "%Margin" := -100; (or whatever value you want to assign in these cases) just to complete your instructions Suresh [;)] Saludos Nils

Thanks guys. I have tried this out and it works great…