5 Replies Latest reply on May 21, 2013 7:53 AM by ninja






           Hi Guys,

           I'm new in FMP12 and I need to do this calculation:

           I have 3 fields:

      Field 1 (Package Name) Packages are: (Orkid, Mawar, Kemboja, Cempaka) which is choosable

      Field 2 (Package Price)   Orkid=RM196, Kemboja=RM136, Mawar=RM116, Cempaka=RM96

      Field 3 (STMB)  is the fix amount:   RM196=STMB (RM52) ,  RM136=STMB (RM32) , RM116=STMB (RM30) , RM96=STMB (RM10)

           When I choose the Orkid Package from field 1 which is drop down menu, then outomaticly show RM196 in Field 2 (Package price) and show RM52 in Field 3 (STMB).

           Is any body here can help me to do this,




        • 1. Re: Calculation


               There are a couple ways this could be accomplished, I think.


               You can use a script trigger and a script when a Plan name has been chosen.

               Script Trigger: OnObjectSave (or OnObjectModify)


               If ( packageNameField = "Orkid" )

               Set Field [ packagePriceField ; 196 ]

               Set Field [ stmbField ; 52 ]

               Else If (packageNameField = "Kemboja" )

               Set Field [ packagePriceField ; 136 ]

               Set Field [ stmbField ; 32 ]


               End If


               However, that would only update if you use this field on this layout.

               You can also use an autoenter with the "Do no replace existing value of field (if any)" unchecked, and have something similar enter in as the autoenter calculation (Calculated value).

               However, that limits you to only those packages, if you ever need to edit or add a new one, that could get tiresome.

               So if you have a related table of the packages, you can still use the autoenter.  But this time it will call the fields from the related table (connected by relationship with the packageName[ID]).  Then you don't have to worry about the calculations of listing the exact name.

               Hope that helps (HTH)

          • 2. Re: Calculation

                 Or you can avoid the calc altogether and simply have the Package Name as your relational field to the subtable and put the subtable's fields on your layout.

                 When a package is entered, it will connect via the relationship and thus show the other two fields on your layout.

            • 3. Re: Calculation

                   Welcome back Ninja!

                   I recommend Ninja's approach. It allows you change the values returned via a data entry operation instead of having to redesign the calculation each time.

              • 4. Re: Calculation

                     Yes, if you just want to show the data from a related table, then Ninja's suggestion would work.

                     If you need to edit the values (ex. special discount price for a package, save for historical purposes in case prices change), then copying the values may be better.

                     Which you can still do the data entry layout, and use the autoenter with only the field from the related table in it (Not the calculation with the package names).

                • 5. Re: Calculation

                       IT User makes a fine point...the setting of a field rather than allowing future automatic change.

                       If this is needed, I would do it by lookup rather than embedding the result in a calc.  As Phil mentions, digging into a calc every time you want to change something get burdensome.  Additionally, it puts your users into the file functions where they should never be. 

                       Autoenter Lookup, or script trigger launching a ReLookup from the related table would be safer.

                       If you want the values to "change live", just use the active relationship itself.