简体   繁体   中英

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.

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.

eg

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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