Crystal Report formula to get costs

I am trying to create a new version of a customer pack slip in E10, so that when we ship FOC items overseas, we have a document for customs purposes that shows the cost value. I have got all the details on the the report and am having trouble with the following formula, that will pull the cost depending on If statements,.

If ({shipdtl.OurJobShipQty} > 0) then ((({JobAsmbl.TLALaborCost} + {JobAsmbl.TLABurdenCost} + {JobAsmbl.TLAMaterialCost} + {JobAsmbl.TLASubcontractCost} + {JobAsmbl.TLABurdenCost}) / {JobHead.ProdQty}) * {shipdtl.OurJobShipQty})
else
If ({shipdtl.OurInventoryShipQty} > 0) and ({Part.CostMethod} = “A” and {PartCost.CostID} = “1”) then (({PartCost.AvgLaborCost} + {PartCost.AvgBurdenCost} + {PartCost.AvgMaterialCost} + {PartCost.AvgSubContCost} + {PartCost.AvgMtlBurCost}) * {shipdtl.OurInventoryShipQty})
else
If ({shipdtl.OurInventoryShipQty} > 0) and ({Part.CostMethod} = “S” and {PartCost.CostID} = “1”) then (({PartCost.StdLaborCost} + {PartCost.StdBurdenCost} + {PartCost.StdMaterialCost} + {PartCost.StdSubContCost} + {PartCost.StdMtlBurCost})*{shipdtl.OurInventoryShipQty})
else 9999.99

This formula works ok if we are shipping direct from a job, but fails if shipping from inventory.

If I rem out the first If and Else, it will run for an inventory part with on problem.

If I remove this field from the report it wil load data no matter if it is a shipment form a job or inventory, so that tells me there is a problem with this formula, but for the life of me I can’t see it, so am hoping that someone can take a look and tell me where I’m going wrong.

Thanks in advance for any help.

Have you tried breaking this up into “sub” formulas? Just to if/how each displays as standalone items in your report?

Also I wonder if there could cause a division error from the JobAsmbl fields.
Did you already set “Default values for Nulls” in your formula?
Or try adding an extra condition?
e.g.

If ({shipdtl.OurJobShipQty} > 0)
AND ({JobAsmbl.TLALaborCost} + {JobAsmbl.TLABurdenCost} + {JobAsmbl.TLAMaterialCost} + {JobAsmbl.TLASubcontractCost} + {JobAsmbl.TLABurdenCost}) > 0
then
((({JobAsmbl.TLALaborCost} + {JobAsmbl.TLABurdenCost} + {JobAsmbl.TLAMaterialCost} + {JobAsmbl.TLASubcontractCost} + {JobAsmbl.TLABurdenCost}) / {JobHead.ProdQty}) * {shipdtl.OurJobShipQty})
else…