View Full Version : problem with IIF function


knightwest
04-26-2007, 07:02 AM
hello again,
have written the following IIF function, which works
IIf([G/L acct]=54201,"y","")
so, if the general ledger account is equal to 54201, then put a "y" in the field, otherwise leave blank.

The problem arises because I need 2 more accounts flagged with a "y"
I have written the following SQL:
IIf([G/L acct]=54201,"y","") Or IIf([G/L acct]=54601,"y","") Or IIf([G/L acct]=54211,"y","")

This returns a "-1" in the field for all accounts, irrespective of what the account is.

How do arrange this so that only the three accounts get flagged with a "y"

Thanks for reading this.

Knightwest

DJkarl
04-26-2007, 07:30 AM
hello again,
have written the following IIF function, which works
IIf([G/L acct]=54201,"y","")
so, if the general ledger account is equal to 54201, then put a "y" in the field, otherwise leave blank.

The problem arises because I need 2 more accounts flagged with a "y"
I have written the following SQL:
IIf([G/L acct]=54201,"y","") Or IIf([G/L acct]=54601,"y","") Or IIf([G/L acct]=54211,"y","")

This returns a "-1" in the field for all accounts, irrespective of what the account is.

How do arrange this so that only the three accounts get flagged with a "y"

Thanks for reading this.

Knightwest

Try this:
IIf([G/L acct] = 54201, "y", IIf([G/L acct] = 54601, "y", IIf([G/L acct] = 54211, "y", "")))

knightwest
04-26-2007, 07:35 AM
That works like a treat.

Thank you.

Jon K
04-26-2007, 07:35 AM
Or alternatively,

IIf([G/L acct]=54201 Or [G/L acct]=54601 Or [G/L acct]=54211,"y","")

Or simply,

IIf([G/L acct] IN (54201,54601,54211),"y","")
.

knightwest
04-26-2007, 07:37 AM
I like the last one best, I will try it.