Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

IIF statement

Discussion in 'Information Technology' started by Levans digital, Jul 28, 2006.

Tags:
  1. Levans digital

    Levans digital
    Expand Collapse
    Guest

    How can I write (If [pounds] >= [cubicfeet]â€50 and if [cubicfeet] is null
    use [pounds] otherwise the field is empty.

    Below is what I have. I suspect I am missing the part “and if [cubicfeet] is
    null†please help.
    CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")
     
  2. Loading...


  3. Larry G.

    Larry G.
    Expand Collapse
    Guest

    Here is the format of an Iif statement, iif(logical test, value if true,
    value if false)

    so depending on what you want, you need to determine where to nest your
    second iif statement. I think this is what you are looking for:

    CalLBS: iif([Pounds]>=[Cubicfeet]*50,[pounds],iif([cubicfeet] is
    null,[pounds],"" ))
    --
    Never give up, the answer IS out there, it just takes a while to find it
    sometimes!


    "Levans digital" wrote:

    >
    > How can I write (If [pounds] >= [cubicfeet]â€50 and if [cubicfeet] is null
    > use [pounds] otherwise the field is empty.
    >
    > Below is what I have. I suspect I am missing the part “and if [cubicfeet] is
    > null†please help.
    > CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")
    >
     
  4. Wolfgang Kais

    Wolfgang Kais
    Expand Collapse
    Guest

    Hello.

    "Levans digital" wrote:
    >
    > How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
    > null use [pounds] otherwise the field is empty.
    >
    > Below is what I have. I suspect I am missing the part "and if [cubicfeet]
    > is null" please help.
    > CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")


    IIf(([Pounds]>=[Cubicfeet]*50) or ([cubicfeet] is null),[pounds],Null)

    --
    Regards,
    Wolfgang
     
  5. Carl Colijn

    Carl Colijn
    Expand Collapse
    Guest

    In news:E45E78ED-63EE-45A5-AE34-7488AB627387@microsoft.com,
    Larry G. <LarryG@discussions.microsoft.com> typed:
    > "Levans digital" wrote:
    >> How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
    >> null use [pounds] otherwise the field is empty.
    >>
    >> Below is what I have. I suspect I am missing the part "and if
    >> [cubicfeet] is null" please help.
    >> CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")

    >
    > Here is the format of an Iif statement, iif(logical test, value if
    > true, value if false)
    >
    > so depending on what you want, you need to determine where to nest
    > your second iif statement. I think this is what you are looking for:
    >
    > CalLBS: iif([Pounds]>=[Cubicfeet]*50,[pounds],iif([cubicfeet] is
    > null,[pounds],"" ))


    Or simply use the old logic setup, thus avoiding nesting the IIf's (and
    having to duplicate the [pounds] parameter);
    IIf( ([pounds] >= [cubicfeet] " 50) Or ([cubicfeet] is null), [pounds], "")

    However, as a note to Levans, as I and Larry already implied from your
    question is that you want to use an OR in stead of an AND; USE [pounds]
    IF EITHER [pounds] >= [cubicfeet]"50 OR [cubicfeet] is null

    Kind regards,
    Carl
     
  6. Levans digital

    Levans digital
    Expand Collapse
    Guest

    Hey all you guys thanks. I tried Wolfgang/s solution and it worked perfectly.

    However I used his concept to create another expression with simular outcome
    but it did not work
    here is my expression I want to fix:
    CalKGtoLBS: IIf([Kilograms]>=[CubicMeters]*800.92,[kilograms]*2.2046)

    Here is what I want to do:
    Again I want to accomplish if [Kilograms]>=[CubicMeters]*800.92 or if
    [cubicmeters] is null use ,[kilograms]*2.2046) otherwise use null

    again my expression is missing out "or if [cubicmeters] is null" I tried
    several what arnt I getting?

    Here is one expression I made copycatting wolfgang's expression:
    CalKGtoLBS: IIf(([Kilograms]>=[CubicMeters]*800.92 Or ([CubicMeters] Is
    Null),[kilograms]*2.2046),Null)
    but when I ran the query it says "Syntax error "comma" in query expression

    Help

    "Wolfgang Kais" wrote:

    > Hello.
    >
    > "Levans digital" wrote:
    > >
    > > How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
    > > null use [pounds] otherwise the field is empty.
    > >
    > > Below is what I have. I suspect I am missing the part "and if [cubicfeet]
    > > is null" please help.
    > > CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")

    >
    > IIf(([Pounds]>=[Cubicfeet]*50) or ([cubicfeet] is null),[pounds],Null)
    >
    > --
    > Regards,
    > Wolfgang
    >
    >
    >
     
  7. Wolfgang Kais

    Wolfgang Kais
    Expand Collapse
    Guest

    Hello "Levans digital".

    "Levans digital" wrote:

    >>> How can I write (If [pounds] >= [cubicfeet]"50 and if [cubicfeet] is
    >>> null use [pounds] otherwise the field is empty.
    >>>
    >>> Below is what I have. I suspect I am missing the part "and if
    >>> [cubicfeet] is null" please help.
    >>> CalLBS: IIf([Pounds]>=[Cubicfeet]*50,[pounds],"")


    >> IIf(([Pounds]>=[Cubicfeet]*50) or ([cubicfeet] is null),[pounds],Null)


    > Hey all you guys thanks. I tried Wolfgang/s solution and it worked
    > perfectly.
    >
    > However I used his concept to create another expression with simular
    > outcome but it did not work Here is my expression I want to fix:
    > CalKGtoLBS: IIf([Kilograms]>=[CubicMeters]*800.92,[kilograms]*2.2046)
    >
    > Here is what I want to do:
    > Again I want to accomplish if [Kilograms]>=[CubicMeters]*800.92 or if
    > [cubicmeters] is null use [kilograms]*2.2046) otherwise use null
    >
    > again my expression is missing out "or if [cubicmeters] is null" I tried
    > several what arnt I getting?
    >
    > Here is one expression I made copycatting wolfgang's expression:
    > CalKGtoLBS: IIf(([Kilograms]>=[CubicMeters]*800.92 Or ([CubicMeters] Is
    > Null),[kilograms]*2.2046),Null)
    > but when I ran the query it says "Syntax error "comma" in query
    > expression


    There are too many closing brackets. Delete the bracket in "2.2046),Null".

    --
    Regards,
    Wolfgang
     

Share This Page