6 Replies Latest reply on Oct 7, 2015 12:56 PM by disabled_user25789

    "Clicking" a checkbox by a calculation ..

      Hi,

       

      I have added to a FileMaker 14 form two new fields:

      • Give-away poster (checkbox)
      • Number of posters


      I'd like to make the life for the users easy, so I'd like to do the following:

      • If the user sets "Number of posters" to anything bigger than 0, then the checkbox is automatically set. Unset, if the field is set to 0
      • If the user clicks on the "Give-away poster", then the value of "Number of poster" is set 1 (default value). If it is unchecked, then the field "Number of posters" is set automatically to 0


      The "Give-away poster" is Text field with a single-value list behind (only value is "Give-away poster"

       

      I tried to do something by adding a calculation to the field, but nothing worked so far.

       

      Many thanks in advance for any suggestions

       

      Kind regards,

      Thomas

        • 1. Re: "Clicking" a checkbox by a calculation ..
          skywillmott

          There are a few ways this could be done using script triggers and/or buttons attached to the fields... See attached example file, which has the checkbox specified as a button which fires a script to change the field values, and the qty field has a script trigger which also adjusts things accordingly....

           

          hope this helps,

           

          Sky.

          • 2. Re: "Clicking" a checkbox by a calculation ..
            Mike_Mitchell

            Thomas -

             

            You have a circular set of requirements. You want the value in each field to be set based on input in the other. That won't work using strictly a calculation, because the values will override each other and you won't be able to edit either one. In order for this to work, you'll need to use either a pair of scripts or a script in combination with a calculation.

             

            You can use the checkbox as a button to trigger a script, for example, that performs these steps:

             

            1) Checks the existing status of the checkbox (on or off - populated or not)

            2) Sets the Number of Posters field to the new value appropriately

            3) Toggles the checkbox to its other value

             

            Similarly, you can use the OnObjectSave Script Trigger to create a script that:

             

            1) Checks the value just entered in the Number of Posters field

            2) Sets the value in the Give-away Poster field appropriately (which will set the checkbox)

             

            That would be my recommended approach.

             

            HTH


            Mike

             

            Edit: I see Sky has already done what I was suggesting. This forum really needs an auto-refresh feature ...  

            • 3. Re: "Clicking" a checkbox by a calculation ..
              user19752

              For resolving circular, you can use Get(ActiveFieldName)

               

              checkbox auto enter calculation

              Case ( Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) = GetFieldName ( Self ) ; Self ;

              Number > 0 ; "Give-away poster" ; "" )

              number field

              Case ( Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) = GetFieldName ( Self ) ; Self ;

              Give away = "Give-away poster" ; 1 ; 0 )

               

              There is disadvantage, you can't use script "Set Field" without activating these fields.

               

              "Give-away poster" is not good name for field that contains minus sign.

              • 4. Re: "Clicking" a checkbox by a calculation ..

                Hi Sky,

                 

                Thanks for the code.

                 

                Is there a way that I can look at your lines (e.g. on TextEdit) before loading the to Filemaker? My account has admin rights, so I don't want to upload that directly into the Filemaker system.

                 

                Many thanks

                 

                Kind regard,
                Thomas

                • 5. Re: "Clicking" a checkbox by a calculation ..
                  skywillmott

                  Hi Thomas,

                   

                  You can take a look at the two scripts in my sample file I posted to see what's going on, as well as go into Layout mode and see the script trigger that is assigned to the Qty field, as well as how the checkbox is defined as a button....

                   

                  Hope this helps....