need help with a seemingly simple IIF statement

S

Scott B

Greetings,

I write a lot of IIf statements, but for some reason this one is giving me a
fit. Does anyone see my mistake? It is eluding me.

Many thanks,
Scott

= ("Staying for " & (IIf ([StayLength]) = "1", " Night" , " Night(s)"))
 
N

Nikos Yannacopoulos

Scott,

Redundant parentheses, and quotes around 1 while [SatyLength] is
numeric? Try:

= "Staying for " & IIf([StayLength] = 1, " Night" , " Night(s)")

HTH,
Nikos
 
S

Steven Greenberg

Scott,

Redundant parentheses, and quotes around 1 while [SatyLength] is
numeric? Try:

= "Staying for " & IIf([StayLength] = 1, " Night" , " Night(s)")

HTH,
Nikos

Scott said:
Greetings,

I write a lot of IIf statements, but for some reason this one is
giving me a fit. Does anyone see my mistake? It is eluding me.

Many thanks,
Scott

= ("Staying for " & (IIf ([StayLength]) = "1", " Night" , "
Night(s)"))

also do you want it to output something like:

Staying 1 Night
Staying 3 Night(s)

or

Staying Night
Staying Night(s)

if you want the first, then you must also include the StayLength variable
in the statement.

="Staying for " & StayLength & IIf([StayLength] = 1, " Night" , "
Night(s)")

if the second, then the previous suggestion will work.
 
V

Van T. Dinh

If [StayLength] is numeric, you should remove the String delimiters. Also,
some parentheses are not needed and some are wrongly placed.

Try:

= "Staying for " & IIf ([StayLength] = 1, " Night" , " Night(s)")
 
S

Scott B

Nikos,

BINGO!

Thanks,
Scott B

Nikos Yannacopoulos said:
Scott,

Redundant parentheses, and quotes around 1 while [SatyLength] is numeric?
Try:

= "Staying for " & IIf([StayLength] = 1, " Night" , " Night(s)")

HTH,
Nikos

Scott said:
Greetings,

I write a lot of IIf statements, but for some reason this one is giving
me a fit. Does anyone see my mistake? It is eluding me.

Many thanks,
Scott

= ("Staying for " & (IIf ([StayLength]) = "1", " Night" , " Night(s)"))
 
B

BruceM

On another point completely, why the parentheses around the "s"? Seems to me
the second choice will only appear if the number is 2 or greater, so plural
is not optional.

Scott B said:
Nikos,

BINGO!

Thanks,
Scott B

Nikos Yannacopoulos said:
Scott,

Redundant parentheses, and quotes around 1 while [SatyLength] is numeric?
Try:

= "Staying for " & IIf([StayLength] = 1, " Night" , " Night(s)")

HTH,
Nikos

Scott said:
Greetings,

I write a lot of IIf statements, but for some reason this one is giving
me a fit. Does anyone see my mistake? It is eluding me.

Many thanks,
Scott

= ("Staying for " & (IIf ([StayLength]) = "1", " Night" , " Night(s)"))
 
S

Scott B

just a typo on my part. Forgot to eliminate it.

Thanks,
Scott B

BruceM said:
On another point completely, why the parentheses around the "s"? Seems to
me
the second choice will only appear if the number is 2 or greater, so
plural
is not optional.

Scott B said:
Nikos,

BINGO!

Thanks,
Scott B

Nikos Yannacopoulos said:
Scott,

Redundant parentheses, and quotes around 1 while [SatyLength] is
numeric?
Try:

= "Staying for " & IIf([StayLength] = 1, " Night" , " Night(s)")

HTH,
Nikos

Scott B wrote:
Greetings,

I write a lot of IIf statements, but for some reason this one is
giving
me a fit. Does anyone see my mistake? It is eluding me.

Many thanks,
Scott

= ("Staying for " & (IIf ([StayLength]) = "1", " Night" , "
Night(s)"))
 

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