7 Replies Latest reply on Sep 24, 2010 8:28 AM by philmodjunk

    Calculations re-calculate when I go back to look at a record

    user14830

      Title

      Calculations re-calculate when I go back to look at a record

      Post

      Hello all!

      Thanks again for all the help you folks provide.  I am using FM11 Pro on a Macbook Pro.  I have a database that has many calculations within each record.  

      When I review my previous records, I notice that the calculation totals change when I exit a record and re-enter it for review.  Why is this happening???  How do I stop it???

      Thanks for your help!

        • 1. Re: Calculations re-calculate when I go back to look at a record
          philmodjunk

          We'd need to know a lot more about how you've defined these calculations, any relationships that might be involved and exactly what you mean by "exit a record and re-enter it for review".

          • 2. Re: Calculations re-calculate when I go back to look at a record
            user14830

            Certainly Sir, I'll do my best.

            All of my calculations are in the same table and on the same layout, (or record).

            When I 'scroll' through records I've already entered data into, I notice that reloading the record seems to make the calculations re-calculate.  Is there a way to review previously entered records without them modifying themselves??

            I do have a script set to trigger on the record load, but there are no calculations in it.

            Thanks in advance for your help.  I hope I explained it well enough for you to answer.

            • 3. Re: Calculations re-calculate when I go back to look at a record
              philmodjunk

              Records do not just "recalculate" unless some other factor is involved.

              Posting your OnRecordLoad script here would be a good idea. It might be a factor.

              Select a calculation that is recalculating and paste the calculation expression here. Let us know if it's from a calculation field or an auto-entered calculation and for calculation fields, whether the field is unstored or stored.

              If I were to make a guess, the calculation is unstored, but can't imagine how the recalculation would even be visible to your as the result of the calculation wouldn't be expected to produce a different value unless there's something out of the ordinary in what/how it calculates.

              • 4. Re: Calculations re-calculate when I go back to look at a record
                user14830

                Here is the script that is triggered with the record load...

                If (__PKHandID = 1)

                Set Field (CountBegin ; Starting_Stack)

                End If

                If (__PKHandsID > 1)

                Set Field (CountBegin ; Total_Last_Hand)

                Basically this script is saying that if the Hand ID, (which is my primary key), is 1, then set the field of CountBegin with the player's starting chip count.  If it does NOT equal 1 then set the field of CountBegin with the player's total from the last hand, (or previous record).

                There are 6 players total, I only put in a small sample of the script for your reference.

                You may remember me Phil. I'm the guy making a database to track the final table of a TV poker show I work for.

                Thanks for your help!

                • 5. Re: Calculations re-calculate when I go back to look at a record
                  philmodjunk

                  That answers about half of what I asked for. What are you seeing on the screen that shows things are recalculating when you reload a record?

                  Those set field field instructions certainly look to me like they might be the culprit as they modify a field on your current record each time a record becomes current (is loaded). Just clicking on a record, clicking the "book" control in the status area, or selecting this layout will trigger that script.

                  • 6. Re: Calculations re-calculate when I go back to look at a record
                    user14830

                    That's a great point Phil.  Below is a screen shot of the calculations.  Since the script trigger DOES set the field of 'BeginingCount' to either the starting stack or the total count from the previous hand, I can see how this will effect the calculations.  

                    Is there a fix to this?  Where would you recommend I trigger this script to have the total count from the previous hand be the beginning count for the next hand without having the calc fields 're-calculate'.

                    Thanks again.


                    • 7. Re: Calculations re-calculate when I go back to look at a record
                      philmodjunk

                      I can't see any screen shot and I can't really answer your questions specifically.

                      The basic question you have to answer is: "when does this calculation need to update and when does it not?" If you can select a script trigger that ties directly to a user action that always requires the recalculation and avoids the unintended recalcs, you've got it.

                      An alternative, is to use a global variable such as $$CalcEnable to turn the feature on and off.

                      A button could be used to toggle the value of this variable:

                      Set Variable [$$CalcEnable ; Value: Not $$CalcEnable ]

                      Then enclose your script in an If block that tests this variable:

                      If [$$CalcEnable]
                      ///your current script goes here
                      End If

                      Another possible "fix" is to create a different layout that does not have this script trigger and you would use it for reviewing your records without triggering recalculations.