• IIF query (Access 2000)

    Author
    Topic
    #443589

    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

    Viewing 2 reply threads
    Author
    Replies
    • #1070300

      Edited by HansV to correct error

      Replace [pack] at the end of the expression with

      IIf(>5;[pack];)

      Note for others reading this thread: keks uses a system on which comma is the decimal separator and semicolon is the list separator.

      • #1070301

        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(=20;2,66;IIf(=60;6,27;IIf(=180;6,18;IIf(=205;19;IIf(=210;19;0))))))))))))/IIf(>5];[pack];)

        • #1070303

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

    • #1070306

      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.

    • #1070376

      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.

      • #1070377

        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.

        • #1070394

          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.

    Viewing 2 reply threads
    Reply To: IIF query (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: