12 Replies Latest reply: Feb 1, 2016 9:50 AM by Jerry Svensson RSS

    Variables, Triggers and the Back button

    Jordi Camps

      Hi,

       

      In my QVW, I'm using a trigger event to change the value of a variable when the selection changes. So, when I make a selection, the event triggers and the variable changes. So far, so good. My problem is with the back button: the first time I click on BACK the variable rolls back, and I need a second "Back" click to undo the original variable. This is not acceptable since the variable value is related to the selection, and a single "back" leaves an incorrect state.

       

      A simple attached xample might help:

           - field MYFIELD, values 1,2,3

           - variable MYVAR

           - Objects: MYFIELD Listbox, and MYVAR Textbox.

       

      There is a ONSELECT trigger on Myfield, that sets MyVar as "=10*Myfield".

       

      First, select "1" on MyField. the event triggers and sets the MyVar as 10*1... so the TextBox displays "10".

      Repeat with "2", same logic and the TextBox displays "20".

       

      So far, so good.

       

      BUT, if I click "back", the VAR is rolled back to "10" BUT NOT the Field. This results in having on-screen the value "2" still selected, but the textbox displays "10"..... obviously, not 10 times the selected value

       

      I dont know how to avoid the "variable change" being inserted in the "back pile". Any other workaround would be also apreciated.

       

      Note that I know i could set MyVar directly as an expression so that it evaluates automatically, without a trigger. The problem is, this formula is very complex, and the same value is used over 50 times in a single sheet. For some reason QV does not cache the result, so it is evaluated 20 times in a single tab making the sheet unusable.