Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iff 3

Status
Not open for further replies.

loneranger27

Programmer
Apr 22, 2003
94
0
0
US
Hi,

I have a calculated text box that gets its value from one of 3 subforms. is there a way to put more that one condition into the iff() format?

for example

if [type]="row" or [type]="spade" then [textbox123]=forms![tom]![calc]

how can I format this into an 1ff statement?

Any ideas would be appreciated.
 
iff ([type]="row";[textbox123]=forms![tom]![calc])
You can not use the &quot;or&quot; in an iff you can only use if/then/else i.e. iff(A<1;B=4;B=2) the ; sign stands for the &quot;then/else&quot;



Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Hi loneranger27,

You should be able to use an or within your condition. What you can't do is give both sides of an assignment within the IIf construct; you assign the results of an IIf to a variable. To get what you want, you should be able to set the control source of textbox123 to ..

Iif([type]=&quot;row&quot; or [type]=&quot;spade&quot;,forms![tom]![calc],&quot;&quot;)

Enjoy,
Tony
 
I had the impression that this Iff was to be used in a query hence the &quot;;&quot; if used in code - where I would never use an &quot;iff&quot; - the &quot;,&quot; is used.

But acc to Tony we can use &quot;or&quot; in an iff and I did not know this, shame on me ;-) - Thx Tony!

Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
And just for the fun of it, you can do this in an IIf statement without using the OR
Code:
=IIf(([type]=&quot;row&quot;),forms![tom]![calc],IIf(([type]=&quot;spade&quot;),forms![tom]![calc],&quot;&quot;))
NOTE: This is only to show that you can nest IIf statements. TonyJollans's approach is far more efficient for this question.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
hermanlaksko (and other non US members):

The &quot;;&quot; vs &quot;,&quot; buggered me somewhat too. Found out it has to do with the decimal separator. For those of us not using the US decimalseparator (.), but rather a comma (,), commas cannot be used as separators between arguments, so, at least where I reside, we have to use &quot;;&quot;.

Ordinary &quot;US&quot; syntax for Iif is represented above, but when we do queries, controlsource, excel formulas etc... we'll have to use for instance:

[tt]=IIf(([type]=&quot;row&quot;);forms![tom]![calc];IIf(([type]=&quot;spade&quot;);forms![tom]![calc];&quot;&quot;))
[/tt]

(using CajunCenturions example )

Roy-Vidar (.no)
 
Thanks RoyVidar - that is very useful information.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I keep learning new things today

Thx Roy-Vidar I did not know that the &quot;;&quot; - &quot;,&quot; had to do with the country code, as I use a US system but live and work in .DK
But it makes sence in a M$-kind of way ;-)

Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Hi Roy,

Very interesting. I didn't completely follow Herman's post - now I do.

Star from me too.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top