Expression Help

T

Ted

I'm trying to write and expression that will assign a text
value depending on an account number. Here is what I have
so far:

IIf([Account]=61101,"Store" Or [Account]=90122,"OSR")

It assigns the "OSR" value correctly, but returns a "-1"
for all accounts that should have "Store".

Any ideas where I'm missing the boat?
 
J

John Vinson

I'm trying to write and expression that will assign a text
value depending on an account number. Here is what I have
so far:

IIf([Account]=61101,"Store" Or [Account]=90122,"OSR")

It assigns the "OSR" value correctly, but returns a "-1"
for all accounts that should have "Store".

Any ideas where I'm missing the boat?

The IIF function has three arguments:

1. A logical expression which evaluates to TRUE or False
2. A value to be returned if the expression is TRUE
3. A value to be returned if the expression is FALSE

So it's checking for account 61101; if that is true it's returning the
value

"Store" OR [Account] = 90122

which will be interpreted as a logical expression and will (I'd guess)
return -1 since the text string STORE is nonzero.

If you want to return STORE for account 61101 and return OSR for
account 90122, I'd suggest using the Switch() function instead of IIF:

Switch([Account] = 61101, "Store", [Account] = 90122, "OSR", True,
"Something else")

Alternatively, especially if you have more than three or four Accounts
to display, add a Text AccountType field to your Accounts table and
display *it*.
 
T

Ted

-----Original Message-----
I'm trying to write and expression that will assign a text
value depending on an account number. Here is what I have
so far:

IIf([Account]=61101,"Store" Or [Account]=90122,"OSR")

It assigns the "OSR" value correctly, but returns a "-1"
for all accounts that should have "Store".

Any ideas where I'm missing the boat?

The IIF function has three arguments:

1. A logical expression which evaluates to TRUE or False
2. A value to be returned if the expression is TRUE
3. A value to be returned if the expression is FALSE

So it's checking for account 61101; if that is true it's returning the
value

"Store" OR [Account] = 90122

which will be interpreted as a logical expression and will (I'd guess)
return -1 since the text string STORE is nonzero.

If you want to return STORE for account 61101 and return OSR for
account 90122, I'd suggest using the Switch() function instead of IIF:

Switch([Account] = 61101, "Store", [Account] = 90122, "OSR", True,
"Something else")

Alternatively, especially if you have more than three or four Accounts
to display, add a Text AccountType field to your Accounts table and
display *it*.


.
Hey John,

I was just wondering if you looked like Yoda becuase you
answers always make you sound like him. :>)

Thanks for the help. Everytime you have responded the
answer has been correct and accompanied by an
understandable explanation. I appreciate your help and the
opportunity to learn.
 
J

John Vinson

I was just wondering if you looked like Yoda becuase you
answers always make you sound like him. :>)

<snork!>

You can see a picture of me on the CompuServe website, if it really
matters. Yoda's MUCH more handsome.
Thanks for the help. Everytime you have responded the
answer has been correct and accompanied by an
understandable explanation. I appreciate your help and the
opportunity to learn.

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top