简体   繁体   English

MS Access上溢-处理除以0

[英]MS Access Overflow - Dealing with division by 0

I have the following expression in an MS Access Query, where some of these values can be null and despite the cast to a Decimal and the Not Zero (NZ) function, I still get an overflow error. 我在MS Access查询中具有以下表达式,其中某些值可以为null,尽管强制转换为Decimal和Not Zero(NZ)函数,但仍然会出现溢出错误。

Sum(Cdec(Nz([TotalPrice]/([tbl_ArticlesPerOrder]![Amount]*[Total])*[tbl_ArtikelRemoveFromSawList]![Amount]),0))

EDIT: Removing the TotalPrice division removes the overflow. 编辑:删除TotalPrice除法将删除溢出。 So I suspect a division by 0. Any way to deal with that? 因此,我怀疑除数为0。有什么办法可以解决?

I would try to see if you can build an IFf statement within your sum to handle the division by zero. 我将尝试查看是否可以总和构建IFf语句来处理被零除的问题。

eg 例如

IIf([tbl_ArticlesPerOrder]![Amount]*[Total])=0,0,[TotalPrice]/([tbl_ArticlesPerOrder]![Amount]*[Total])

MS LINK: Avoiding divide by zero errors in Access MS LINK:避免在Access中除以零错误

(Edited based on Kev's comments) (根据Kev的评论进行编辑)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM