2014-04-02 39 views
0

我从VB.NET应用程序启动查询(Access 2003)。iif功能访问 - 错误结果

select id, customer, date, total, iif ([amountGet] - [amountSent] = [total], 'Yes', 'No') as result from invoices

IIF返回错误结果


ID:1
客户:佩佩
日期:2014年1月1日
总:1,8
amountGet:5
amountSent:3,2

结果:
返回 “无”

时应该返回 “是” 因为5-3,2 = 1,8

+2

什么类型是amountGet,amountSent和total?这很可能是由于舍入错误。 – jpw

+0

Double(自动小数) – kontable

+0

难道你的区域设置使用','而不是'.'来表示小数位?你有没有试过在即时窗口运行这个? – Zaider

回答

1

四舍五入号码相同数量的小数,在我案例2位小数,返回正确的结果:

iif (round([amountGet] - [amountSent],2) = round([total],2)) 

@jpw感谢您的评论,因为它帮助我找到解决方案