4 Replies Latest reply on Nov 13, 2008 9:35 AM by ThomasB

    Conditional finds

    ThomasB

      Title

      Conditional finds

      Post

      Hello

      Can anyone tell me how to make a find request conditional on another field?

      I would like to put two global fields with radio buttons in the footer and have FM find the results that match the current settings of these two fields.

       

       

        • 1. Re: Conditional finds
          Orlando
            

          Hi ThomasB

           

          This is relatively simple to achive.

           

          You will need to setup a script using ScriptMaker to do this and attach that script to a button on the layout that the user will click after inputting the criteria in the global.

           

          The script will then go into find mode, and using the Set Field script step set the field you wish to search on with the value of the global field. 

           

          You might also want to check the result first to make sure something is found and alert the user if not so there is an If statement to check the found count and alert the uer if nothing is found.  

           

          The script would look like this:

           

           Allow User Abour [Off]

           Set Error Capture [On] 

           #

           Enter Find Mode [] // Deselect 'Pause' 

           Set Field [ Table::TextField ; Table::GlobalSearchField ]

           Perform Find [] 

           # 

           #// Check result and if no records found alert user.

           If [ Get ( FoundCount ) = 0 ]

             Show Custom Dialog ["Message" ; "No Records Found."]

             Enter Browse Mode []

           End If 

           #

           

          You can then add things like "New Record/Request" if you want to perform the same search on additional fields.

           

          Let me know if there is anything unclear or you wish me to expand upon. 

           

          • 2. Re: Conditional finds
            ThomasB
              

            Thank you for your fast reply.

            I didn't manage to get your solution to work and I'm not sure whether it's because I didn't understand it properly or if I didn't describe the problem correctly.

            I've put a very light (154kb) example database here: 

             

            http://www.blackthorne.it/CARGO/DataFace.fp7 

             

            I would like to be able to make a selection of the radio buttons in the footer and hit the "FIND" button and see the results appear in the list above.

             

            Sorry if I've missed the obvious and thanks for any help you can give. The  database is a very simple example of a type of find I'm always trying to do so if I understand the concept here you will have helped a lot.

             

            Thomas 

            • 3. Re: Conditional finds
              Orlando
                

              Not a problem Thomas, glad to help.

               

              I have downloaded the file and just want to check the type of find you want to perform.

               

              Do you want to perform and AND search on the two fields or and OR search?

               

              The results would be very different. for example an AND search in your file would give you 3 records of people with Fair hair and No glasses, where as an OR search will give you 4 records, all the people with Fair hair and all people with no glasses. 

               

              Either way the basic script is as below, just add or remove the 'New Record Request' step depending on what you require.

               

               Allow User Abour [Off]

               Set Error Capture [On] 

               #

               Enter Find Mode [] // Deselect 'Pause' 

               Set FieldExample::Hair ; Example::HairSwitch ]

               New Record/Request // Include if an OR search

               Set FieldExample::Glasses ; Example::GlassesSwitch ] 

               Perform Find [] 

               # 

               If [ Get ( FoundCount ) = 0 ]

                 Show Custom Dialog ["Message" ; "No Records Found."]

               End If 

               # 

               

              • 4. Re: Conditional finds
                ThomasB
                  

                Perfect. I compiled the script and it worked like a dream.

                 

                Now I've got the concept I'll be using this everywhere!

                 

                Thank you.

                 

                Thomas