9 Replies Latest reply on Apr 23, 2015 5:32 AM by erolst

    Checkbox Script Help Please!

    jjgarner

      Hello everyone,

       

      I am new to FileMaker and I would love getting some help with a Button related issue. I am currently struggling with making scripts that create, set or change the Values in a given Field.

       

      I have a bunch of buttons on a layout, and I want them to function as checkboxes that will do an awesome script: I want a box that is checked to enter data into a specific Field in that layout.

       

      Here is my example:

      Screen Shot 2015-04-22 at 12.04.12 PM.png

      So, as you can see, I want the three checkboxes on the right to be useful by defining the value of the "Multiple Birth" Field for a given person / Record.

       

      If I click on the "Yes" checkbox, I want the "Multiple Birth" Field to have a vale of "Yes" and if I click the "No" checkbox I want the value in that "Multiple Births" Field to be "No" and so on. It doesn't have to be text; it could be 1s and 0s if that is necessary - I just want to connect the buttons to the field I want to control.

       

      This would really, really help me out in my work and I really appreciate any and all help.

       

      Thanks in advance!

        • 1. Re: Checkbox Script Help Please!
          coherentkris

          Setting up a field to display a pop-up menu, checkbox set, or other control

           

          if you define your checkbox as having a value list of Yes No as its data source then you dont need the "blank" choice.

          • 2. Re: Checkbox Script Help Please!
            thurmes

            Is there any reason you want to do this with checkboxes? The behavior you describe is exactly what you get with radio buttons (you can only play one station on the radio at one time), whereas checkboxes are used for situations where you can have more than one checkbox checked (for example, a field with fruit color might show the bananas as both yellow and green at the same time). So to get what you want, set the field up as a radio button field.

             

            It is possible to set it up as a checkbox if you really, really want to, but that involves having scripts that are triggered to eliminate other entries.

            • 3. Re: Checkbox Script Help Please!
              siplus

              something like this ?

              • 4. Re: Checkbox Script Help Please!
                jjgarner

                Thanks to everyone who replied so swiftly! thurmes is probably correct - I should use radio buttons because checkboxes are intended to "stack" with each other, and I don't want that at all.

                 

                Thanks again, you guys rock.

                • 5. Re: Checkbox Script Help Please!

                  First create a value list with your three values and give it a name.

                  Put your field on a layout and use the inspector, Data tab, to assign the field as a radio button and use the value list you created.

                  Now the radio buttons will show your values and the one you select will be entered into the field.

                   

                  Place a plain text field next to the radio button so you can see the value entered into the field.

                   

                  Note that searches using the status bar cannot be used with a radio button or checkbox to find empty fields...

                   

                  Since you've already set this up, its possible you have more than one valuein the field and you'll need to clean that up.

                   

                  Using the field definitions you can set a default value to be entered when you create the record.

                  • 6. Re: Checkbox Script Help Please!
                    rgordon

                    There isn't a need to create scripts to trigger an elimination other entries.  Using the following auto-enter calculation will accomplish this: RightValues(self;1).  Uncheck the Do not replace existing value of field.

                    • 7. Re: Checkbox Script Help Please!
                      erolst

                      rgordon wrote:

                      RightValues(self;1)

                       

                      With the caveat that the xValues() functions add a trailing CR; so as an alternative:

                       

                      GetValue ( self ; ValueCount ( self ) )

                      • 8. Re: Checkbox Script Help Please!
                        rgordon

                        My values are a little suspect .  I forgot to add a substitute to the calc. Usually use Substitute(RightValues(Self;1);"¶";"") which removes the CR.  I always find the CR annoying when finding one value with a Value function.  Not sure what the purpose of the CR is since I can easily add a CR to the calc if needed.

                        • 9. Re: Checkbox Script Help Please!
                          erolst

                          rgordon wrote:

                          Not sure what the purpose of the CR is since I can easily add a CR to the calc if needed.

                          According to the Documentation: "Each value that is returned ends with a carriage return, allowing lists to be easily concatenated." There, it's supposed to be a convenience feature …

                           

                          Here's hoping for a modernized syntax that allows something like

                           

                          GetValue ( someList ; -1 ) // last item

                          GetValue ( someList ; 1..3 ) // items 1 and 2

                          GetValue ( someList ; 1...3 ) // items 1-3

                           

                          which would do away with xValues (and hopefully the trailing CR, too).