2 Replies Latest reply on Jun 6, 2013 2:48 PM by philmodjunk

    How to retain filter when performing find or sort



      How to retain filter when performing find or sort


           My database includes a field called "Active", which specifies whether the record is active or not.  If the record is active, the value for the field will be  "Active".

           I have a script set to run when opening the layout which will only find records that are active.  As soon as a user clicks the Find to search within the report for specific data, it shows all data, not just the ones listed as active.

           Is there a way to force this script to run and limit records to only showing the "Active" data when a find is performed?

           In the layout setup I have this script enabled in Browse, Find, and Preview on OnLayoutEnter and OnViewChange events.

           If someone performs a find, the script does not run and the only way to get the "report" back to normal is to leave it and open it again.

        • 1. Re: How to retain filter when performing find or sort

               What I always do in these situations is create a text field on the top of the layout. Next to it a "Find" button and a "Show All" or "Reset" button that brings you back to the original found set (only active records).

               You could also add buttons like: "Show all active" or "Show all inactive".

               All these buttons should perform scripts.

               For the search field it should be a text field set to global storage.

               Then a script could look something like:

               Enter Find Mode [ Uncheck the pause button ]
               Set Field [ Table::FieldToBeSearched ; Table::GlobalSearchField ]
               Set Field [ Table::Active ; "Active" ]
               Set Error Capture [On]
               Perform Find
               Sort Records [If neccessary]


          • 2. Re: How to retain filter when performing find or sort

                 Write this script:

                 Enter Find Mode []
                 Set field [YourTable::Active ; "Active"]
                 Constrain Found Set []

                 Then, on your layout, set up the OnModeExit with the Find mode selected to perform this script.

                 This leaves two menu options that can still bring non active records into your found set: Show All Records and Show Omitted Only. With FileMaker Advanced, you can set up custom menus that either remove these menu options or replace them with scripts that only show all active or all active omitted records.