8 Replies Latest reply on Jul 13, 2013 7:46 AM by philmodjunk

    Division illogical



      Division illogical


           I have a calculation field where a simple division operation is not working; but if I replace de division symbol (/) by an *, then the calculation works fine :

           field1 = field2 / field3     --> (this calculation not work; as "field3" changes, the result in "field1" keeps displaying the first calculation made with the first value used in "field3"

           field1 = field2 * field3     --> (this calculation works fine; as "field3" changes, the result in "field1" change too 

           Please someone explain what I'm wrong. I wonder if can upload my file to be revised ??


        • 1. Re: Division illogical

               How did you set this up in Manage | Database | Fields?

               Is the first calculation set up on a field of type number with the expression specified as an auto-enter calculation? Could "field3" be from a related table? Or could the "do not replace existing value..." check box be selectged?  If so, the value returned will not update when field3 is modified.

          • 2. Re: Division illogical

                 First of all, thanks for replying.

                 My field3 is the calculation result from other fields that are specified as auto-enter calculation.

            Any sugestion to get my calculation work?


            • 3. Re: Division illogical

                   Could you please sugest a solution for my calculation, but without the use of scripts?


              • 4. Re: Division illogical

                     Make it a field of type calculation instead of a number field with an auto-entered calculation. If you change the field type, your calculeted expression will not be lost.

                • 5. Re: Division illogical

                       If I do that, the field won't be modifiable. And I need it modifiably.

                       Is there a way to create a calculated field to take the value of my field and use it in my division?


                  • 6. Re: Division illogical

                         What you asks seems a touch contradictory: You want the field to update automatically when field3 is modified but you also want to directly edit they value in this field. What should happen to the value in this field if you edit it and then the value in field3 changes?

                         It may help to take a step back from the mechanics involved and describe the actual field and how you need to use it.

                         WIthout going there, you have two options: An update script--which you have already rejected or two fields in place of one. FIeld 1 would be the above field redefined as a calculation field and modififed to also refer to an Override field:

                         If ( Isempty ( OverrideField ) ;  field2 / field3 ; OverrideField )

                         On your layout, you then place your Overrirde Field, with a transparent fill color, on top of your current field. When you click or tab into the Override field, you can enter a specific value. If you do not enter a value, the calculation is visible. Use conditional formatting to make the calculation field invisible when there is data in the Override field.

                    • 7. Re: Division illogical

                           Now I see it clear... Thanks. But just in case.. could you please guide me in update script option?? (sorry)


                      • 8. Re: Division illogical

                             If you have two tables linked like this:


                             TableA::__pkTableAID = TableB::_fkTableAID

                             For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

                             And Field3 is defined in TableA while the field with auto-entered calculation resides in TableB....

                             A script similar to this might be set up with the onObjectSave trigger on Field3 on the layout where users are allowed to edit the value:

                             If [ TableB::_fkTableAID // true only if related records exist in TableB ]
                                  Freeze Window
                                  Go To Related Record [Show only related records; From table: TableB; Using layout: "TableB" (TableB) ]
                                  Replace Field Contents [no dialog; TableB::Field1 ; TableB::field2 / TableB::field3 ]
                                  Go To Layout [original layout]
                             End IF