Search code examples
ms-accessiif

iif function Access - wrong result


I am launching a query (Access 2003) from VB.NET app.

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

but iif returns wrong results

TABLE
id: 1
customer: pepe
date: 01/01/2014
total: 1,8
amountGet: 5
amountSent: 3,2

RESULT:
Returns "No"

when should return "Yes" because 5-3,2=1,8


Solution

  • rounding numbers to same number of decimals, in my case 2 decimals, returns correct result:

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

    @jpw thanks for the comment, because it has helped me to find the solution