6 Replies Latest reply on Dec 16, 2015 3:10 PM by macwombat

    Dropdown box selection edits record

    MJMWeb

      Hello, I'm new to Filemaker and am using Filemaker Pro 14.  I'm having a few issues with what should be relatively simple procedures. Perhaps I'm misunderstanding something fundamental about the program, but I'm attempting to display data, not edit it. Yet I can't select anything from a dropbox without editing the value of the record it is based on.

       

      I have a table named "clients". It had a primary key of "client_ID", and two fields "Last Name" and "First Name". I added those fields to the view and populated a drop down box with the client_ID records. I want to be able to select an ID from the dropbox and have the record change based on the result. Preferably, it would look to see what record that result is on and go to that record, so if my table is:

       

      Row      client_ID    First Name

      "Row 1"             5            John

      "Row 2"             6            Chris

      "Row 3"             1            Carol

       

      and I select the third row with a value of 1, it will see it's the third record and thus navigate to the third record rather than the first. So Carol will appear in the First Name edit box, not John. I can get it to work using this script:

       

      Set Variable: [$IDVar; Value :clients;clientID]

      Go to Record/Request/Page[$IDVar];

       

      but that prompts me to confirm the record selection each time. I don't know why this isn't working.

       

      There's another problem as well, which is that selecting an item from the dropdown list will edit the previous selection. So if I enter browse mode and the dropdown box defaults to 6 and I click on it and select 1, now both Row 2 and Row 3 have a client_ID of 1.  Does anyone have any idea what is going on here?

        • 1. Re: Dropdown box selection edits record
          SteveMartino

          What is happening is the dropdown field change is just editing the record.  What would work better is to not let the user change the name in the record at all.

          Create a field, make it global, call it gSearch.  Populate it with a value list based on the primary key, and using a concatenated first & last name.

          OnObjectModify script trigger to perform the follow script

          Set Variable (to id value in global field)

          Enter Find Mode (uncheck pause)

          Set Field (id field with variable)

          Perform Find (no parameters)

          • 2. Re: Dropdown box selection edits record
            planteg

            Hi,

             

            to achieve that, add a new field to your table, and make storing global (that means the same value for all records). I can't 'show' you, I am on a PC with no FM installed. Assign the same value list to this new field. When the user pick a choice, then go the corresponding record. On your layout, only make that field editable !

             

            EDIT

             

            Steve just beat me on this one !

            • 3. Re: Dropdown box selection edits record
              macwombat

                Hi.  Welcome to FM & the TechNet community.  There are plenty of good training resources available on this website to help you learn to make the most of FM.  I would highly recommend Database Skills, FileMaker Pro Training | FileMaker.

               

              To answer your question:  to choose records with a dropdown without changing data you need to create a new field - call it "ClientChooser" or something like that.  When creating the field, click the options button (bottom right of the Manage Database dialog window) or double click the field to edit it's options.  Click the storage tab.  Click the "Use global storage" option.

               

              Then place this field on your layout as the chooser field.  Set it up as a dropdown list - getting its value from the ClientID field.  On you field set script trigger to run the script "OnObjectModify".

              The script should now be:

              Enter Find Mode [ ]

              Set Field [clients::clientID ; clients::ClientChooser ]

              Perform Find [ ]

               

              Oh - a couple of other guys got in before me!

              • 4. Re: Dropdown box selection edits record
                MJMWeb

                So, I know how to use a managed list to add the primary key, and I could add a second value of either First or Last name, but I don't know how to concatenate them inside the managed list.

                 

                I did as you said and it didn't validate properly. Here is what my script looks like:

                 

                script.png

                • 5. Re: Dropdown box selection edits record
                  MJMWeb

                  Okay, this worked, although it was not intuative how to get both variables into Set Field. It's also not immediately clear that line does. Why is it Clients::clientID first and then the global variable?

                  • 6. Re: Dropdown box selection edits record
                    macwombat

                    The logic of the script is this:

                    1.  Go into find mode.

                    2.  Set a value in the Clients::clientID field that you want to find (in this instance the value that has been selected in the global field - ie. clients::ClientChooser).

                    3.  Perform the Find:  ie. Find the record that has a clientID that is the same value as the global field.