1 2 Previous Next 22 Replies Latest reply on Jun 7, 2017 3:50 PM by SMGreenfield

    check box to indicate yes or no

    jeffsb

      I am working on my first FileMaker application, for a nonprofit organization whose board i am on.

       

      On the layout screen on which information about people who come to us is entered, we have several yes or no type fields. For instance a person might be a prisoner or a subscriber to our newsletter.

       

      The way I thought to do it would be to have a number field that would have either a one or a zero in it. On the data entry screen if there was a one in that field there would be a check box with a check in it. If there is a zero in the field there would be a box without a check in it. To indicate that someone is a prisoner you would click on the box which would then turn from an empty box to a box with a check mark in it on the screen. The question is how to do this. Or if you have a alternate solution to this I'd be interested in hearing that. Thank you for any help that you can give me with this.

        • 1. Re: check box to indicate yes or no
          rouelf

          A drop-down list with: Yes and No values should work for you:

           

          FileMaker Pro 15 Help

          • 2. Re: check box to indicate yes or no
            BMyers

            Jeff, this is a common question.  I put the best method I've discovered into the answer for another forum discussion. It has a step-by-step that you can follow.  You can take a look at it here: Show/Hide, Calculation, or set field. Which is faster?

            • 3. Re: check box to indicate yes or no
              philmodjunk

              A simple number field formatted as a check box with a value list of 1 is all that you need. Just size the field to hide the one.

              • 4. Re: check box to indicate yes or no
                BMyers

                Exactly, Phil.  There are two tricks that aren't in the documentation that are key:

                 

                1.  The notion that a checkbox should use a value list with one value, 1.  I suspect most beginners define the value list as 1, 0 and that leads them to frustration.

                 

                2.  How to get the field data to toggle between 1 and 0.  Simply making a value list with the single number 1 creates a toggle between 1 and empty, which isn't the same thing.  To toggle between 1 and 0 can be done with a script or an auto-entry calculation, and I would guess that beginners would not know how to do it correctly.  I sure didn't.  It's not in the documentation.

                 

                Too bad this question keeps coming up on the forum.  It's tough to be a beginner and be stymied at something as simple as a checkbox.

                • 5. Re: check box to indicate yes or no
                  philmodjunk

                  "Simply making a value list with the single number 1 creates a toggle between 1 and empty, which isn't the same thing. "

                   

                  While that is true, much of the time, empty and 0 can be treated as equivalent in FileMaker Solutions.

                  • 6. Re: check box to indicate yes or no
                    jeffsb

                    Thank you, BMyers!!    I've pasted your correct answer in this post, since you made it in another thread and just gave a link to it here. But how it works is mysterious to me. I put it in a field that denotes whether a person gets the newsletter or not, and sure enough, every one  with a "1" in it showed a checked box and every one with a "0" showed the empty box.

                     

                    But I have two (beginners) questions. You said, "You can make the checkbox any size, but I use Height 13, Width 14."  What units are the 13 and 14? Points? The second question is, what is the actual content of a field with an empty box and a field with a checked box? Is it still "0" and "1"? Thank you.

                     

                     

                     

                     

                    **********************************************************************************

                    **********************************************************************************

                    BMyers answer, which worked for me:

                    by BMyers on Jan 24, 2017 8:01 PM

                    I'd like to suggest another method because simple checkboxes are one of those things that should be simple but aren't in FMP.  I looked a long time before I found this method.

                     

                    Advantages:

                      - Simple and fast

                      - Can be copied and pasted quickly to other layouts or tables (just change the table::field setting in the Inspector)

                      - No "hide object when" so it's faster to re-use anywhere in an app

                      - Works in Find Mode

                     

                    Disadvantages:

                      - You can sorta emulate the standard OSX-style blue checkbox, but it's not quite identical.

                      - Stuck with the simple checkmark, no fancy graphics.  But this method is so easy to implement that the restriction is worth it.

                     

                    Field Setup:

                    The type of field is Text

                     

                    Auto-Enter

                      - Use calculated value: If ( IsEmpty ( YourTable::YourField ) ; 0 ; 1 )

                      - All other boxes unchecked

                     

                    Validation - check these:

                      - Validate date Only During Data Entry

                      - Allow user to override during data entry

                     

                    Storage Options - Use Default

                     

                    Value List Setup:

                    In the Inspector, under the Data Tab,

                      - Use Control Style called Checkbox Set

                      - Create a Value List with only one value, the number 1

                      - Specify a checkmark or an X to go in the box

                     

                    Styling Setup:

                    In the Inspector, under the Appearance Tab,

                      - Under Style it should say Checkbox Set

                      - Where the box says "Checkbox Set" the four options (Normal, Hover, Pressed, In Focus) should have no formatting

                      - Change the box to "Checkbox Set:Checkbox"  This is the background of the checkbox, so your pick.  I set Normal to white and use a light blue for Hover.  Pressed and In Focus are white.

                      - Change the box to "Checkbox Set:Icon"  This is the color of the checkmark, so your pick.  I use OSX blue for mine.

                     

                    Also under the Appearance Tab,

                      - You can make the checkbox any size, but I use Height 13, Width 14

                      - Alignment left and top

                      - Padding:  This is key: set padding to “left 6” to get the number 1 in the checkbox set to disappear.  All that will appear is the box itself.

                     

                    I created a FMP Style called Checkbox Field that sets all of this.

                    • 7. Re: check box to indicate yes or no
                      jeffsb

                      @Bmyers Also, you say, "To toggle between 1 and 0 can be done with a script or an auto-entry calculation, and I would guess that beginners would not know how to do it correctly.  I sure didn't.  It's not in the documentation." What would the script or auto-entry calculation look like and how would you apply them. Another beginners question. And also, what would be the reason to do this, instead of just leaving it the way it is?

                      • 8. Re: check box to indicate yes or no
                        jeffsb

                        @philmodjunk

                         

                        You said: "

                        "Simply making a value list with the single number 1 creates a toggle between 1 and empty, which isn't the same thing. "

                         

                        While that is true, much of the time, empty and 0 can be treated as equivalent in FileMaker Solutions."

                         

                        When would it make a difference? Should I find some way to convert "1" and empty  to "1" and "0"?

                        • 9. Re: check box to indicate yes or no
                          philmodjunk

                          If the field is empty, performing a find for 0 won't find that record. An empty field can't be used to match values in a relationship. But if you add values or use it in a Boolean expression, "" and 0 evaluate the same. An average will calculate differently as well.

                           

                          If zero is needed, you can set the field to auto-enter the 0

                           

                          if ( IsEmpty ( self ) ; 0 )//clear the do not replace check box

                          • 10. Re: check box to indicate yes or no
                            Malcolm

                            to add to philmodjunk's post.

                             

                            When using the number formatting options for Boolean, an empty field is not formatted. The field must contain the value zero to be formatted as false.

                             

                            Also, empty, zero and one are three separate states.

                             

                            malcolm

                            2 of 2 people found this helpful
                            • 11. Re: check box to indicate yes or no
                              BMyers

                              Jeff wrote:

                              Also, you say, "To toggle between 1 and 0 can be done with a script or an auto-entry calculation, and I would guess that beginners would not know how to do it correctly.  I sure didn't.  It's not in the documentation." What would the script or auto-entry calculation look like and how would you apply them. Another beginners question. And also, what would be the reason to do this, instead of just leaving it the way it is?

                               

                              Answer by Brian:

                              I think I understand your question but let me know if I'm off base.  FMP allows a user to specify that a field has certain contents every time a record is created, by default.  You can also specify that FMP fill in a field automatically by calculation. 

                               

                              Here's where it is: A user defines new fields in File>Manage Database.  Go to the fields tab at the top of the page.  Now look at the bottom of the page.  There's a blank line where a user can create new fields.  To the right of that line there is a selection box to determine what kind of field it is.  We want text for this.  Next to that on the right is a button called Options.  Click on that and there will be a box with four tabs at the top, and the first one is Auto-Enter.  Almost to the bottom of the box is a choice for Auto-Enter by Calculation.  Check the box and hit the button for Specify.  Put this in the blank: ( IsEmpty ( YourTable::YourField ) ; 0 ; 1 )

                               

                              When you create a new record, this calculation starts by putting a 0 in the field.  If you click on the checkbox, this calculation toggles the entry between 0 and 1 (or any other two you want to use for another purpose). This isn't only calculation that works.  There are a couple of other calcs that do the same thing but I don't have them handy.  Hope this helps.

                              1 of 1 people found this helpful
                              • 12. Re: check box to indicate yes or no
                                SMGreenfield

                                Since you're one of the most expert moderators here, perhaps you can answer:

                                 

                                Why is it that after 16 major releases, FileMaker Pro can't just create a UI component that simply handles what people expect from basic checkbox behavior?  It should't be this hard for newbies (and frankly experienced programmers that are new to FileMaker) to utilize the basic behavior of the simplest of UI components.

                                • 13. Re: check box to indicate yes or no
                                  philmodjunk

                                  A) I'm not a forum moderator

                                  B) "Why" questions would have to be answered by someone who works for Filemaker inc.

                                  C) Never had any real problems with check boxes. A single value value list of 1 nearly always works for me. In other cases, this simple script step works as the action for a button:

                                   

                                  Set Field [ table::BooleanField ; Not table::BooleanField ]

                                   

                                  While technically, a null value and zero are not the same, I find that in the vast number of cases, it's not a significant difference.

                                  2 of 2 people found this helpful
                                  • 14. Re: check box to indicate yes or no
                                    SMGreenfield

                                    Thanks!

                                     

                                    OK, well that wasn't too difficult.  I think it's funky that you need to create the value list of "1", and then have to create a separate label for the checkbox.  It really could be an all-in-one UI component, and I'm guessing there must be some good reason it isn't...

                                     

                                    I just assumed the "mod" was for "moderator"...

                                    1 2 Previous Next