14 Replies Latest reply on Oct 25, 2013 9:19 AM by CraigWollman

    Button to sort

    CraigWollman

      Title

      Button to sort

      Post


           I have two buttons above two different fields.  One is a numeric field and one is a text field.  The button above the numeric field does a sort on the numeric field and works fine but the button above the text field does nothing when clicked.

           When I go to Layout mode, right click on either button and choose "Button Setup," I see that in both cases "Perform Script" is selected under the CONTROL heading.  Both are set to PAUSE in the Current Script: field.  If I click on the "Specify" button "Sort by invoice" is selected for the numeric field sort button and "sort by from (other)" is selected for the text field button (from (other) is the name of the text field, invoice is the name of the numeric field)

           So I see no significant difference in the set ups of the two sort buttons but only one works.  Any suggestions are welcome.  Thanks for your help.

        • 1. Re: Button to sort
          philmodjunk

               Since your button is performing a script, it would seem that the "sort by from (other)" script has a problem. With the specify script dialog up, select "Edit" from the gear drop down (I'm assuming you have FileMaker 11 or newer) and you'll be able to open and examine the script. There should be a sort records script step that you can double click to see what fields have been selected for its sort order.

          • 2. Re: Button to sort
            CraigWollman

                 Hmm, I'm using Filemaker Pro 8.5.  In this version, when I click "Specify Script" there is an edit button but it's in the Optional Parameter section of the dialog.  There is nothing in that field on either button.  When I click on Edit, there is nothing selected there either.

            • 3. Re: Button to sort
              CraigWollman

                   My apologies for not having a newer version but I only use Filemaker for this one file.  That's been the case since about 1993.  I forget why I upgraded in 1007 to 8.5 but other than being able to be in sync with those who offer help in this forum, I have no need to spend the money.

              • 4. Re: Button to sort
                philmodjunk

                     Yes, what I described was a new feature of FIleMaker 11 that makes finding the correct script much simpler. In your older version, (In the future please tell us what version you have), you'll need to note the name of the script and use the script manager to find, open and examine the script.

                • 5. Re: Button to sort
                  CraigWollman

                       But I agree, there is SOMETHING different about how those two buttons were created but the only thing I can see now is that one is text and one is numeric.  Everything else seems to be the same.

                  • 6. Re: Button to sort
                    philmodjunk

                         The difference is not the fields, but the script that is performed.

                    • 7. Re: Button to sort
                      CraigWollman

                           I did go to the Scripts/Scriptmaker dialog and could edit the scripts there.  They are as far as I can tell, exactly the same.  I did notice on difference though in the Specify dialog in the Button Setup dialog.  There are two lines in that list of choices that separate the choices into three groups.  The number sort button uses a script in the bottom third of the list and the text sort button (the one that doesn't work) uses one from the top third.  I don't know how to take a screenshot.  I'm using a Mac with windows XP through Parallels.  I looked online how to take a screen shot and it seems that Fn-Shift-F11 should do it but it didn't.  Not sure where the difference is between those groups of scripts.  The middle section is

                           Message Report

                           Message List

                           Open Script

                            

                           The top and bottom sections appear to be actual scripts.

                      • 8. Re: Button to sort
                        CraigWollman

                             Phil, it appears, as I described, that the Scripts menu/ScriptMaker choice is what you're referring to but again, the two scripts appear to be identical.

                        • 9. Re: Button to sort
                          philmodjunk

                               The scripts probably look identical until you double click the sort records script step and check to see what fields are specified for the sort order. The script for sorting on the text field should list that field inside that dialog while the other script should list the number field in the same place.

                          • 10. Re: Button to sort
                            CraigWollman

                                 I figured it out.  I must have copied the numeric sort button and changed what I thought I needed to change to make it work but I hadn't drilled down deep enough.  Thanks for your inspiration. It helped me get to the right place.

                                 Given that the sort now works but only in either descending or ascending but not both.  Is there a way to have it sort by either on every other button click.  In other words, the first time I click, it sorts ascending, then the second time, it sorts descending and so forth?

                            • 11. Re: Button to sort
                              philmodjunk

                                   This can be done. I am guessing that 8.5 supports using variables. If not, a global field can be used in place of the global variable in this example:

                                   IF [$$Sort]
                                      Sort Records [Restore ; no dialog ]---> specify a descending sort order
                                   Else
                                       Sort Records [Restore ; no dialog ]---->specify an ascending sort order
                                   End IF
                                   Set Variable [ $$Sort ; Value; Not $$Sort ]----> use set field if you have to use a global field here

                                   You can use a differently named variable for each of your two sort scripts.

                              • 12. Re: Button to sort
                                CraigWollman

                                     Looks like you beat me to it but I hadn't seen your latest post.  Thanks again.  It appears there's no way to have a button toggle between a sort ascending so I guess the only solution is to put two buttons by each field to do that.

                                • 13. Re: Button to sort
                                  philmodjunk

                                       You are still missing my latest post. It's quite possible to do.

                                  • 14. Re: Button to sort
                                    CraigWollman

                                         Sorry for the mistiming Phil.  I'll give that script a try.  I'll have to figure out how to add that code to a script but I won't bother you with that, I'm sure it's pretty simple.  And there are SOME things I can do on my own ;)

                                          

                                         Thanks again for your help.