IIf Statement

G

Guest

I need help to write an "IIF" statement for the following:

I have 4 unbound controls on my form that have values in them that need to
be selected for a calculation depending on specific data in my [LBS] field. I
have another unbound control where the calculation will be. Here's an example:

If [LBS] = < 50 then use "unbound1". If [LBS] = < 100 then use "unbound2".
If [LBS] = < 200 then use "unbound3". If [LBS] = < 300 then use "unbound4".

How would I write this with multiple statements?
 
T

tina

multiple nested IIf() functions would do it, as

IIf([LBS] < 51, [Unbound1], IIf([LBS] Between 51 And 100, [Unbound2],
IIf([LBS] Between 100 And 200, [Unbound3], [Unbound4])))

the above expression assumes that [LBS] will 1) never be Null, and 2) it's
acceptable to use [Unbound4] for any value over 200. i would probably use a
custom function with a Select Case statement instead, really just for ease
of reading; but i couldn't tell you if that would be faster or slower than a
nested IIf, or no appreciable difference.

hth
 
G

Guest

That worked perfectly! Thank you very much!

tina said:
multiple nested IIf() functions would do it, as

IIf([LBS] < 51, [Unbound1], IIf([LBS] Between 51 And 100, [Unbound2],
IIf([LBS] Between 100 And 200, [Unbound3], [Unbound4])))

the above expression assumes that [LBS] will 1) never be Null, and 2) it's
acceptable to use [Unbound4] for any value over 200. i would probably use a
custom function with a Select Case statement instead, really just for ease
of reading; but i couldn't tell you if that would be faster or slower than a
nested IIf, or no appreciable difference.

hth


Secret Squirrel said:
I need help to write an "IIF" statement for the following:

I have 4 unbound controls on my form that have values in them that need to
be selected for a calculation depending on specific data in my [LBS] field. I
have another unbound control where the calculation will be. Here's an example:

If [LBS] = < 50 then use "unbound1". If [LBS] = < 100 then use "unbound2".
If [LBS] = < 200 then use "unbound3". If [LBS] = < 300 then use "unbound4".

How would I write this with multiple statements?
 
T

tina

you're welcome! :)


Secret Squirrel said:
That worked perfectly! Thank you very much!

tina said:
multiple nested IIf() functions would do it, as

IIf([LBS] < 51, [Unbound1], IIf([LBS] Between 51 And 100, [Unbound2],
IIf([LBS] Between 100 And 200, [Unbound3], [Unbound4])))

the above expression assumes that [LBS] will 1) never be Null, and 2) it's
acceptable to use [Unbound4] for any value over 200. i would probably use a
custom function with a Select Case statement instead, really just for ease
of reading; but i couldn't tell you if that would be faster or slower than a
nested IIf, or no appreciable difference.

hth


Secret Squirrel said:
I need help to write an "IIF" statement for the following:

I have 4 unbound controls on my form that have values in them that need to
be selected for a calculation depending on specific data in my [LBS] field. I
have another unbound control where the calculation will be. Here's an example:

If [LBS] = < 50 then use "unbound1". If [LBS] = < 100 then use "unbound2".
If [LBS] = < 200 then use "unbound3". If [LBS] = < 300 then use "unbound4".

How would I write this with multiple statements?
 

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