Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IIF query (Access 2000)

    I need a help to refine my IIF clause in a query. The query gives certain values depending of the size and then divides this value to the pack.However, I need to divide the value to

  2. #2
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIF query (Access 2000)

    Thank you for your kind reply.I somehow cannot get it right, sicne the error says The expresion has an invalid syntax missing operator. Where is exactly my fault ?It works in the old way, with pack only.Thank you in advance

    Surcharge: IIf([Size]=1;0,138;IIf([Size]=0,4;0,138;IIf([Size]=0,5;0,138;IIf([Size]=4;0,552;IIf([Size]=10;0,552;IIf([Size]=5;0,552;IIf([Size]=18;2,48;IIf([size]=20;2,66;IIf([size]=60;6,27;IIf([size]=180;6,18;IIf([size]=205;19;IIf([size]=210;19;0))))))))))))/IIf([size]>5];[pack];[size])

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IIF query (Access 2000)

    Edited by HansV to correct error

    Replace [pack] at the end of the expression with
    <code>
    IIf([size]>5;[pack];[size])
    </code>
    Note for others reading this thread: keks uses a system on which comma is the decimal separator and semicolon is the list separator.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IIF query (Access 2000)

    Sorry, there was an error in the expression I posted. There shouldn't be a ] after 5. I have corrected my previous reply.

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: IIF query (Access 2000)

    BTW, you might want to investigate using the Switch() function instead of all the embedded IIF() functions. You might find it a little easier to read/write the code.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    Lounger
    Join Date
    Nov 2002
    Location
    Farnborough, Hampshire, England
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIF query (Access 2000)

    Here's another idea: could you have another table linking the various sizes to the related value? This table could be included in the query, linked by the size, to return the required value, thereby replacing the nested IIFs. You could then use the latter part of your clause to divide by [pack] if required.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IIF query (Access 2000)

    That would be my preferred solution, but having answered hundreds of questions by Keks and his colleagues, I doubt that (s)he wants to use it.

  8. #8
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: IIF query (Access 2000)

    It makes so much sense to use a table to do this, pespecially when you need t add new ones, or alter existing ones, or even deleting certain conditions.

    You dont have to struggle with a hard coded iif to work it out, just make changes in the table and away you go, simple.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IIF query (Access 2000)

    I agree completely, Pat.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •