MS Access上溢-处理除以0 [英] MS Access Overflow - Dealing with division by 0

查看:172
本文介绍了MS Access上溢-处理除以0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MS Access查询中具有以下表达式,其中某些值可以为null,尽管强制转换为Decimal和Not Zero(NZ)函数,但仍然会出现溢出错误.

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

删除TotalPrice除法将消除溢出.所以我怀疑除数为0.有什么办法可以解决?

解决方案

我会尝试查看您是否可以在您的总和内构建IFf语句以处理被零除的问题.

例如

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

MS LINK:避免在Access中除以零错误

(根据Kev的评论进行编辑)

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.

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

EDIT: Removing the TotalPrice division removes the overflow. So I suspect a division by 0. Any way to deal with that?

解决方案

I would try to see if you can build an IFf statement within your sum to handle the division by zero.

e.g.

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

MS LINK: Avoiding divide by zero errors in Access

(Edited based on Kev's comments)

这篇关于MS Access上溢-处理除以0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆