13 Replies Latest reply on Apr 11, 2011 7:47 AM by BatuhanGizer

    Making a field visible through a choice

    BatuhanGizer

      Title

      Making a field visible through a choice

      Post

      Hi,

      I am trying to make a field with radio button.  When the user checks 'Yes' from the radio button, another drop-down field becomes available for user to choose a value from a value list.  If the user checks 'No', the drop down list will not be seen and the user will continue to enter information.

      Thanks!

        • 1. Re: Making a field visible through a choice
          philmodjunk

          There are two basic methods for hiding and revealing layout objects:

          Use a Portal to a related record.

          You can use a relationship that include matching "yes" in the radio button to a field that stores "yes" in the related record. Clicking yes establishes a valid link to a record in the related table and thus the layout objects (fields, text, buttons, whatever...) will then appear.

          Use an invisible tab control.

          Create a tab control with two tabs. Give each tab an object name. Set the color and border properties to match the layout background and so that the tab control is invisible. Then use an OnObjectModify script trigger on this field that checks the value of this field and uses go to object to select the appropriate tab to hide or reveal this field. You'd also likely need an OnRecordLoad trigger that performs this same script so that the objects in the tab are correctly hidden/visible when you first bring up that record.

          A Third option only works if your field does not have a visible border. You can remove the field from the tab order and use conditional formatting to change the fields fill color and use text color or text size to hide it's contents when the value of the radio button field is "yes".

          • 2. Re: Making a field visible through a choice
            BatuhanGizer

            I would like to try to use the portal option that you talked about.  Can you give me more information on how to do it? I am actually trying to put a consultant type radio buttion with yes or no choice.  If someone clicks yes, then I would like user to choose what type of consultant they are, i.e. civil engineering, mechanical engineering etc.  So I am not actually relating this from another table.

            Thanks!

            • 3. Re: Making a field visible through a choice
              philmodjunk

              I would like to try to use the portal option...  So I am not actually relating this from another table.

              Technically, you can't use a portal without relating it to another table, but in this case, we can relate the record and its table to itself via a portal.

              1. Define these fields if you do not already have them:
              2. ID  (auto-entered serial number)
                cYesKey (calculation field that returns "Yes" as text [just type "Yes" in quotes as the calculation])
              3. Switch from Manage | Database | Fields to the relationships tab and drag from ID to outside the borders of the Table Occurrence box and then back to ID before releasing the mouse button. Name this new "instance" (a table occurrence) SameRecord.
              4. Double click the line between the two table occurences and add two more fields to the relationship so that you have this relationship:

                YourTable::ID = SameRecord::ID AND
                YourTable::cYesKey = SameRecord::Consultant     (consultant would be your radio button field)

              5. Now place a portal to SameRecord on your layout and put your consultant type field from SameRecord inside the portal. You can set the portal to display only one row, with no scroll bar and you can make the portal boundaries either transparent of of line width 0 so that the portal itself is invisible.
              6. Use an OnObjectModify trigger to perform a script with the single step: Commit Record to force the portal to hide/reveal the field.

               

              Now, when you click Yes in the radio button field, ConsultantType appears in the portal. Click No and it disappears.

              • 4. Re: Making a field visible through a choice
                BatuhanGizer

                I am sorry for all the questions but how can I do the last step you descriped above? OnObjectModify script trigger?

                • 5. Re: Making a field visible through a choice
                  philmodjunk

                  You need Filemaker 10 or 11 to use script triggers. If you haven't used them before, it's a good idea to look up script triggers in FileMaker help to learn the basics.

                  1. Select Manage | Scripts
                  2. Click the New button
                  3. Find the Commit Record step listed on the left and double click it to add it to the script.
                  4. Click OK and save the changes to your script.
                  5. Enter Layout Mode
                  6. Right click (shift click on Mac) the field and select Script Triggers
                  7. Click the check box for OnObjectModify and select the script you have just created.
                  • 6. Re: Making a field visible through a choice
                    BatuhanGizer

                    Ok so here is what I did. 

                    1-) I already have a PIN assigned to every contact I have.  So I only created the cYesKey field with calculation "Yes".

                    2-) I created the relationship with PIN = PIN AND cYesKey = Consultant ( which has a radio button with custom fields "Yes" and "No".

                    3-) I created a portal to SameRecord and only included ConsultantTypes field in the portal.  The field is a dropdown box with 5 different choices defined from a value list. 

                    4-) Created a script with only Commit Record in it.

                    5-) Right clicked on the field inside the portal and set script Trigger OnObjectModify with the new script I created.

                    I don't know if I am doing something wrong but the field in the portal doesn't appear when I click "Yes" on radio button. 

                    • 7. Re: Making a field visible through a choice
                      philmodjunk

                      Make sure that the return type for cYesKey is defined to return "text" not the default "number" setting. You can open Manage | Database | Fields, double click the field definition for this field and check the drop down in the lower left corner of the Specify Calculation dialog.

                      If that's not the reason, check this demo file over to see if you can spot what's different:  http://www.4shared.com/file/Go7xBNdW/SelfJoinPortalToHideField.html

                      • 8. Re: Making a field visible through a choice
                        BatuhanGizer

                        It works!! Now I want to ask another question which would make the first question a bit more complicated for me.  Can I add more items to a radio button field, for example, Client, Potential Client, Consultant, Potential Consultant etc. and when the user chooses one of these from the radio button, different fields show up with different drop down lists.  I think I only need to add the necessary different dropdown lists to the portal but the thing is, how do I tell FileMaker to show the related dropdown list according to the choice based on radio button since there are multiple choices now rather than just "Yes" or "No"?

                        Thanks!

                        • 9. Re: Making a field visible through a choice
                          philmodjunk

                          I'd use a tab control with a tab for each such field as you need a different field for each option rather than just making one related record appear and disappear.

                          An alternative, would be to use the same field for all these options, but use a conditional value list to control what list of values appear when you drop down/pop up the list.

                          Custom Value List?

                          http://help.filemaker.com/app/answers/detail/a_id/5833/kw/conditional%20value%20list

                          • 10. Re: Making a field visible through a choice
                            BatuhanGizer

                            I have read the other forums and tried conditional value list and it seems to work fine.  The only problem I am having now is to order items in the dropdown list or pop-up list my way.  For example, I entered the classification and type data on another table in the way I wanted it to appear.  To be more exact, this is how I entered the data:

                            Client

                            Potential Client

                            Consultant

                            Potential Consultant

                            Operation Vendors

                            Other

                            But on the layout where the dropdown list is, the order is:

                            Client

                            Consultant

                            Operation Vendors

                            Other

                            Potential Client

                            Potential Consultant

                            Thanks alot!

                            • 11. Re: Making a field visible through a choice
                              philmodjunk

                              You are far from the first person to hit that particular limitation to FileMaker value lists (Non custom values are always sorted in ascending order). If you want to add your voice to the many others who have requested this option: http://www.filemaker.com/company/feature_request.html Giving a real life example of why you want to sort the values in other orders should increase the impact of your suggestion.

                              One work around that works for small numbers of values such as this is to define a number field to specify the order and then define this calculation field:    Right ( "            " ; RankField )  // make sure there are at least as many spaces in quotes as the largest value in RankField.

                              Specify this invisible value as column 2 and have the list sort by this column.

                              PS. If I remember right, I learned this trick from a post by Comment.

                              • 12. Re: Making a field visible through a choice
                                BatuhanGizer

                                Thanks alot for all the help! And I submitted a request for sorting.

                                • 13. Re: Making a field visible through a choice
                                  BatuhanGizer

                                  I just have an additional question to conditional formatting solution you suggested.  It has been working very well but now I have another field.  Can I force the third field to be a pre-entered value?  For example:

                                  First Choice       Second Choice       Third Field

                                  Prints                  24x36 Bond          $7.4

                                  Prints                   11x17                 $2.5

                                  Mail                     Next Day             (User Enters Value)

                                  Mail                     2nd Day              (User Enters Value)

                                  So not every choice has a a pre-set value but also allowing others to enter a different value for some choices.

                                  Thanks!