While converting some Access queries to T-SQL, I came across the Access function IIf. I read the documentation here and understand it takes 3 parameters: the expression, the if true, and the if false. What I have yet to find is if the "false" param is required? And if a false is not provided, what is the behavior?
CodePudding user response:
It's IIf
, not IFF
. All arguments are required in VBA and textbox expressions and both must be calculatable (no error result such as DivBy0) because both parts will be calculated - if either errors, the entire expression errors. The IIf() in query works differently - 'falsepart' calculates only if 'truepart' fails and if 'falsepart' is not provided, expression returns Null if 'truepart' fails.
Try some expressions and see what happens. One for testing: IIf(1=2,"T")
.
CodePudding user response:
Yes, it's required, it's actually like an if else statement.
i.e an action occurs if the condition is fulfilled, and another action occurs if condition is not fulfilled