neileg said:
IIF(Mid([Department],3,1)="I","indirect",IIF(Mid([Department],3,1)="D","direct",""))
What Neil has done is to nest 2 IIF statements and include a Mid() function.
An IIf statement can evaluate the value of a field and the answer is always "Yes" or "No"
The Mid() is a way of looking at the value in the department field and counts for 3 characters starting at character 1 (similar to the Right() and Left() functions)
By including it in the IIf statement is it saying this -
"If the 3rd character (starting at 1) in the department field = "I" its is a yes, that means "Indirect" - if its not an "I" its a No so then read the second IIf and If the 3rd character (starting at 1) in the department field = "D" then it is a yes, that means "direct" - if its not a "D" then its nothing ("") "
It knows which table it is because there's only one field called "Department" otherwise you'd get a conflict error.
As an example, you could have 2 codes A = Apple and B = Banana in a field called "Fruit" an IIF statement to get the description would be
IIf([Fruit] = "A","Apple","Banana")
So as there are only 2 values, if its not "A" (the yes its A) it must be B (the no its not A)
Col