5 Replies Latest reply on Aug 18, 2015 9:25 AM by philmodjunk

    Newbie question: Calculations. Must fields appear in layout?

    touchofgray

      Title

      Newbie question: Calculations. Must fields appear in layout?

      Post

      My database includes a field that calculates elapsed time using two other fields that contain the start and end times. I have buttons within my layout that enter the start and end times in those fields. Must these two fields be included in the layout in order for the calculation field to work? Currently, if I omit them from the layout, the calculation field won’t function. 

        • 1. Re: Newbie question: Calculations. Must fields appear in layout?
          philmodjunk

          You can put fields of type calculation on a layout and it will evaluate correctly whether the fields referenced in the calculation are present on the layout or not.

          I think you need to describe your calculation field in more detail and what exactly you mean by "won't function".

          "calculation" fields might be a field of type calculation, a data field such as text or number with an auto-enter calculation or even a data field with a script trigger that uses a script to assign a calculated value. And there are setting differences for each that can make a difference in how they evaluate.

           

          • 2. Re: Newbie question: Calculations. Must fields appear in layout?
            touchofgray

            Here’s the design in detail...

            A button action records the Current Time in a reference field that represents the Start Time.
            A second button action records the Current Time in a second field that represents the End Time.
            A third field contains a calculation that references the Start and End Time fields and calculates the elapsed time.

            For some reason, if I omit the Start and End Time fields from the layout, the third field (calculation field) fails to return a result. However, if I do include the Start and End Time fields in the layout, the third field will populate.

             

             

             

             

             

             

            • 3. Re: Newbie question: Calculations. Must fields appear in layout?
              philmodjunk

              And what exact method did you use to insert the current time in those fields?

              My guess is that you used a script step that starts with "insert".

              If you used:

              Set Field [YourTable::Field ; Get ( CurrentTime ) ]

              The target field would not need to be present on the current layout.

              Script steps that start with "insert" on the other hand silently fail to work if the target field is not present on the current layout.

              • 4. Re: Newbie question: Calculations. Must fields appear in layout?
                touchofgray

                Your hunch is correct! I wasn’t aware of that limitation. Indeed, both the Start Time and End Time fields each had a button to insert the Current Time using the following button action:

                Insert Current Time [Name of TargetTable: :Field]


                I’ll change to buttons’ actions to use the Set Field script you describe.  Thank You

                 

                 

                • 5. Re: Newbie question: Calculations. Must fields appear in layout?
                  philmodjunk

                  The following script steps directly interact with field objects on your layout and thus: a) fail to work if the specified field is not present on the layout and b) the script step trips script triggers such as OnObjectEnter or OnObjectModify if they are set up on the field object:

                  Copy
                  Paste
                  Clear
                  Any script step that has "insert" as the first word of its name.