Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

IIf syntax question

What is wrong with...

=IIf([txtTotalPartNdemand]-([txtWIPqtyAM]+[txtFGqty]+[txtTotWHqty])<0,0,[txtTotalPartNdemand]-([txtWIPqtyAM]+[txtFGqty]+[txtTotWHqty])

--Steve
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

missing paren at end

= IIf([txtTotalPartNdemand] - ([txtWIPqtyAM] + [txtFGqty] + [txtTotWHqty]) < 0, 0, [txtTotalPartNdemand] - ([txtWIPqtyAM] + [txtFGqty] + [txtTotWHqty]))
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...or perhaps you could first explain what happens when you run it...?
Steve ... the IIF did not compile until I added a trailing right Paren ...

mx
IIF Syntax helper:

IIF(True, TruePart, FalsePart)

Having another IIF for TruePart, copy the whole and replace TruPart.

IIF(True, IIF(True, TruePart, FalsePart), FalsePart)
Fill your real values: ex:
IIF(x=2, IIF(y=3, 10, 20), 3)

Having another IIF for FalsePart, copy the whole and replace FalsePart.

IIF(True, TruePart, IIF(True, TruePart, FalsePart))
Fill your real values: ex:
IIF(x=2, 10, IIF(y=3, 10, 20))

Having both TruePart and FalsePart IIFs

IIF(True, IIF(True, TruePart, FalsePart), IIF(True, TruePart, FalsePart))
Fill your real values: ex:
IIF(x=2, IIF(y=3, 10, 20), IIF(y=3, 10, 20))

You can expand by (nesting IIFs) replacing TruePart/FalsePart as presented.
SteveL13
The first problem with your statement was the missing paren ...

mx