IIF Expression Question

A

Alan Balthrop

Is it possible to have more than 2 possibilities when writing an IIF expression inside a query, and if so can the 3rd answer be another
calculation?

I have the following expression setup:

Half: IIf([1st Half Goals]>[2nd Half Goals],1,2)

There are occasions where [1st Half Goals] and [2nd Half Goals] are equal. In this case, I would like to have the expression return "both".

I tried creating a second expression in the query:

Both: IIf([1st Half Goals]>[2nd Half Goals],"both", [Half]

...which worked nicely, but the query would not fuction when I tried hide the [Half] expression (Access XP asked for the value of "Half").


I would not like to have [Both] and [Half] appearing when the querry is run. Is there a way to write one expression to do this, or can I
create an expression based on a 2nd expression that would not be shown when the query is run?


Thank you in advance for any advice you can give!


Alan Balthrop
Team Historian
Dallas Sidekicks Indoor Soccer Club
 
G

Gerald Stanley

You can nest IIf statements e.g.
IIf([1st Half Goals]=[2nd Half Goals],"both", IIf([1st Half
Goals]>[2nd Half Goals],1,2))

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Is it possible to have more than 2 possibilities when
writing an IIF expression inside a query, and if so can the
3rd answer be another
calculation?

I have the following expression setup:

Half: IIf([1st Half Goals]>[2nd Half Goals],1,2)

There are occasions where [1st Half Goals] and [2nd Half
Goals] are equal. In this case, I would like to have the
expression return "both".
I tried creating a second expression in the query:

Both: IIf([1st Half Goals]>[2nd Half Goals],"both", [Half]

...which worked nicely, but the query would not fuction
when I tried hide the [Half] expression (Access XP asked
for the value of "Half").
I would not like to have [Both] and [Half] appearing when
the querry is run. Is there a way to write one expression
to do this, or can I
create an expression based on a 2nd expression that would
not be shown when the query is run?
 

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