0

How to modify multiple if statements (I'm not sure if that's the right way to express it).

In the database below I have two key buttons, I will temporarily call the code in "Key1" "if1". Now I need to run the "if2" code after meeting the "if1" condition "avg(test) = 1", and this code needs to be before "table2.Table3.(Choose := 2)". It seems like after modifying like this the code does not work. How should I adjust it, thank you for your reply.

 

if2:

    if '1' = null then
        '2' := '1'
    else
        if '2' = null then

'3' := '1'

end

(There are errors in the demo code, use this as the reference.)👆

if1:

if avg(test) = 1 then
    table2.Table3.(Choose := 2)
else
    table2.Table3.(Choose := 1)
end

6 replies

null
    • Fred
    • 9 mths ago
    • Reported - view

    I need to run the "if2" code after meeting the "if1" condition "avg(test) = 1", and this code needs to be before "table2.Table3.(Choose := 2)".

    I don't quite understand what you want to happen. Looking at the code for Key2 (if2), everything works:

    if avg(test) = 1 then
        if '1' = null then
            '2' := '1'
        else
            if '2' = null then '3' := '1' end;
            table2.Table3.(Choose := 2)
        end
    else
        table2.Table3.(Choose := 1)
    end
    

    Can you write out the flow you want? Or upload a flow chart?

      • gold_cat
      • 9 mths ago
      • Reported - view

       

      if avg(test) = 1 then
          if '1' = null then
              '2' := 1
          else
              if '2' = null then '3' := 1 end;
              table2.Table3.(Choose := 2)
          end
      else
          table2.Table3.(Choose := 1)
      end

      Hi Fred, the key1 button can be clicked multiple times, and the data that gets modified toggles between "man" and "woman" (displayed in table2); key2 does not work this way, I guess it's because of the "if2" that was added. How can I adjust it to make them both work,

    • Fred
    • 9 mths ago
    • Reported - view
     said:
    I guess it's because of the "if2" that was added. How can I adjust it to make them both work,

    I would agree that key2 doesn't work like key1 because of the second if statement. I asked for a flow chart or a more descriptive paragraph of the if statements on what you want to happen.

    If you add text to the field "1", then key2 works like key1. Just like you wrote the code.

      • gold_cat
      • 9 mths ago
      • Reported - view

       

      Thank you Fred, I didn't think through the problem clearly at first, but now I've solved it using a different approach.

      • Fred
      • 9 mths ago
      • Reported - view

       Maybe you can sharing your solution with the group?

      • gold_cat
      • 9 mths ago
      • Reported - view

       

          if '1' = null then
              '2' := 1
          else
              if '2' = null then '3' := 1
          end;

      if avg(test) = 1 then

          table2.Table3.(Choose := 2)
      else
          table2.Table3.(Choose := 1)
      end

      just like this...

Content aside

  • Status Answered
  • 9 mths agoLast active
  • 6Replies
  • 85Views
  • 2 Following