Reputation: 75
I am trying to use an IIf statement in ms access 2000. I've searched around but have found nothing that accurately describes my situation. The current issue is when I try to use an IIf statement to output an answer dependent upon two parts or variables, it gives me a message stating that my syntax is incorrect. The line of code in question is as follows:
=IIf([Sold]=Yes, And IIF([Paid]=No, Then,"Not Paid"))
It gives me a message saying that my syntax is incorrect but upon removing the comma after the "Yes", it tells me that I've made too few arguments.
Upvotes: 0
Views: 12081
Reputation: 27644
You may be thinking of nested IIf()
statements, but you only need the standard syntax:
IIf ( expr , truepart , falsepart )
expr
is [Sold]=Yes And [Paid]=No
. And there is no Then
in IIf.
So your code should be:
=IIf([Sold]=Yes And [Paid]=No, "Not Paid", "Paid!")
or with a more common way to formulate the bool expression, and an empty falsepart
:
=IIf([Sold] And Not [Paid], "Not paid", "")
Upvotes: 1