iif statement

  • Thread starter Thread starter Joel Allen
  • Start date Start date
J

Joel Allen

I use this IIF statement. It's works great.

IIf([DrawingStage]="New",[JobInitiatedDate],
IIF ([DrawingStage]="Shipped",[ShippedDate],
IIF ([DrawingStage]="Cancelled",[CancelledDate],
IIF ([DrawingStage]="Released",[ReleasedDate],
))))

But what if I need all 4 of them to be true? I've put "and" in between the
IIF statements and it doesn't seem to work.

Thanks
-Jole
 
I need a better explanation. For all four of them to be true, DrawingStage
would have to equal New, Shipped, Cancelled, and Released all at the same
time. What are you trying to accomplish?
 
Joel said:
I use this IIF statement. It's works great.

IIf([DrawingStage]="New",[JobInitiatedDate],
IIF ([DrawingStage]="Shipped",[ShippedDate],
IIF ([DrawingStage]="Cancelled",[CancelledDate],
IIF ([DrawingStage]="Released",[ReleasedDate],
))))

But what if I need all 4 of them to be true? I've put "and" in between the
IIF statements and it doesn't seem to work.

Thanks
-Jole

Have you considered using the Switch- or the Choose-function?

From Access97 Help:

Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])

Choose(index, choice-1[, choice-2, ... [, choice-n]])

Regards
PerL
 
Joel

To follow on Wayne's response, perhaps you could describe how your data is
structured. In a well-normalized database, it wouldn't be possible for a
single field ([DrawingStage]) to hold more than one value in a single
record. So you question about "what if it is all four" does not
compute...<g>
 
Joel said:
I use this IIF statement. It's works great.

IIf([DrawingStage]="New",[JobInitiatedDate],
IIF ([DrawingStage]="Shipped",[ShippedDate],
IIF ([DrawingStage]="Cancelled",[CancelledDate],
IIF ([DrawingStage]="Released",[ReleasedDate],
))))

But what if I need all 4 of them to be true? I've put "and" in
between the IIF statements and it doesn't seem to work.

Thanks
-Jole

OK, have to admit I misunderstood your question when sending my first reply. I just gave you a couple of other functions making you able to choose among distinct values (instead of IIf which, being binary, only chooses one of two [or three, of you consider Nulls]).

But you actually ask "what if I need all 4 of them to be true'". How can DrawingState have all those values on the same time? Do you want the IIf statement to return all four dates, then?????
/
Regards
PerL
/
Have you considered using the Switch- or the Choose-function?

From Access97 Help:

Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])

Choose(index, choice-1[, choice-2, ... [, choice-n]])

Regards
PerL
 
Whoops, I misphrased my example. Ok let's say I want both of these to be
true.....

if DrawingStage = New and JobValue > 1000.0 then output the
JobInitiatedDate.

I hope that makes sense. I'm just having trouble with the syntax in an IIF
statement.

Thank you - Joel

Per Larsen said:
Joel said:
I use this IIF statement. It's works great.

IIf([DrawingStage]="New",[JobInitiatedDate],
IIF ([DrawingStage]="Shipped",[ShippedDate],
IIF ([DrawingStage]="Cancelled",[CancelledDate],
IIF ([DrawingStage]="Released",[ReleasedDate],
))))

But what if I need all 4 of them to be true? I've put "and" in between
the IIF statements and it doesn't seem to work.

Thanks
-Jole

OK, have to admit I misunderstood your question when sending my first
reply. I just gave you a couple of other functions making you able to
choose among distinct values (instead of IIf which, being binary, only
chooses one of two [or three, of you consider Nulls]).
But you actually ask "what if I need all 4 of them to be true'". How can
DrawingState have all those values on the same time? Do you want the IIf
statement to return all four dates, then?????
/
Regards
PerL
/
Have you considered using the Switch- or the Choose-function?

From Access97 Help:

Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])

Choose(index, choice-1[, choice-2, ... [, choice-n]])

Regards
PerL
 
Yes, that makes more sense.

Example:
IIf([DrawingStage]="New" And [JobValue]>1000.0,[JobInitiatedDate],
IIF ([DrawingStage]="Shipped" And [JobValue]>1000.0,[ShippedDate],
IIF ([DrawingStage]="Cancelled",[CancelledDate],
IIF ([DrawingStage]="Released",[ReleasedDate],
))))

If your logic is more complicated, we'll need the entire possible scenario
list to help further.
 

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

Back
Top