4 Replies Latest reply: Jul 25, 2016 4:41 PM by Sunny Talwar RSS

    If statement not working properly

    Alec Whitaker

      Hello, my If statements are not working properly. The idea behind this is that when one clicks on a Code in the Listbox, it will narrow down the results to the ones containing that code. However, if no Code is selected in the listbox, it will display the Sum of the values.

       

      Currently, if the code does not match 1 through 8, it is by default just selecting Code 1 and using those values, rather than the sum of all values as I want it to.

       

      Here is my code:

       

      if(Code = '1', Montreal,
      if(Code = '2', Gagetown,
      if(Code = '3', Valcartier,
      if(Code = '4', Meaford,
      if(Code = '5', Petawawa,
      if(Code = '6', [Edmonton Spares],
      if(Code = '7', Edmonton,
      if(Code = '8', Wainwright,
      (
      Sum(Montreal + Gagetown + Valcartier + Meaford + Petawawa + [Edmonton Spares] + Edmonton + Wainwright))))))))))

       

       

      Any help is greatly appreciated.

       

      Thanks,

       

      Alec