8 Replies Latest reply on Jan 31, 2012 11:57 PM by Sorbsbuster

    Modifying an "OR" find??

    fred@kca-inc.com

      Title

      Modifying an "OR" find??

      Post

       Good Evening,

      I'm trying to create a found set from an "OR" search (initial found set) then constrain the set with a value in a separate field (found set 1).  This part works great:

      Enter Find Mode

      Set Field1 to 1

      New Record

      Set Field1 to 2

      Perform find [to get all records where Field1 = 1 OR 2][initial found set created]

      Enter Find Mode

      Set Field2 to 1

      Constrain Found Set [to get all records with (Field1 = 1 OR 2) AND Field2 = 1)][found set 1 created]

      This where I run into trouble: At this point, I'd like to get back to the "initial found set" (without redoing the initial query) and set Field 2 to 2 and re-query to get found set 2

      Is there a way to do this?  The inital found set query actually has a loop to build the OR function.  Ideally, I'd like to not re-query this due to time constraints because it will have to be done 4 times.

      Thanks

      Fred 

        • 1. Re: Modifying an "OR" find??
          philmodjunk

          From your current setup, getting back to the initial found set requires a new "query" of your table.

          You could modify the above script to enter a 1 in field 2 in each request generated in your loop instead of adding the extra "Constrain" at the end, but you are still making a new query, it's just that you now have the option of using modify last find to get back to the set of requests in order to loop through them to change the 1 in field 2 to a new value...

          There are two ways you can preserve that found set, but I'm not sure either will work for you here.

          1. Two layouts based on different occurrences of the same table will have different found sets, current records, etc. Thus, you can perform different finds on each layout. THus, to get back to your original found set, you can switch to the other layout.
          2. Two windows to the same layout can have different found sets. Thus, you can get a different found set just by opening a new window...
          • 2. Re: Modifying an "OR" find??
            fred@kca-inc.com

             That's an interesting observation.  If I am in Find Mode, can I loop through the "records" that I enter the OR values in as though they were a found set in Browse Mode?  I hadn't thought of that.  Right now, I have a loop embedded within a loop and I'm afraid it will get very slow as the number of records increases.

            Enter Find Mode

            Goto the first record

            Loop

              Enter Field2 criteria

              Go to next record, exit at end

            End Loop

            Perform Find

             

            • 3. Re: Modifying an "OR" find??
              philmodjunk

              Yes you can loop through them (They're called "requests" when you are in find mode.)

              and you don't need to use got to first record immediately after entering find mode, you can leave that step out.

              You'd set it up as:

              Modfy last find

              Loop
                 Set Field [table::field2 ; .....
                 go to record/request/page [next ;exit after last]
              End Loop

              Perform find []

              Such a subsequent find with different criteria for field2 will have the same number of iterations as the first find. Thus, using Modify Find instead of re-entering find mode and starting from scratch may not be much different here in terms of time taken as the only difference is in the number of set field steps inside the loop.

              • 4. Re: Modifying an "OR" find??
                fred@kca-inc.com

                 Very cool! I think that will save me a complete embedded loop and lots of processing time.  Thanks.

                FYI, I've used many development tools over my many years, but I don't think that I've ever used a tool that is so complete as FMP11.  So far, there has been a way to accomplish everything I've needed (many thanks to you and your great support).

                • 5. Re: Modifying an "OR" find??
                  fred@kca-inc.com

                   One more question.  would the "Replace Field Contents" work with the "requests" in find mode to replace Field2 in all of the requests at once?

                  • 6. Re: Modifying an "OR" find??
                    philmodjunk

                    Hmmm... don't know off the top of my head. Why not try it and see what happens?

                    • 7. Re: Modifying an "OR" find??
                      fred@kca-inc.com

                       Just FYI, it doesn't appear that the "Replace Field Contents" works on the request records.  It would be a nice feature to reduce over query time.

                      • 8. Re: Modifying an "OR" find??
                        Sorbsbuster

                        "Just FYI, it doesn't appear that the "Replace Field Contents" works on the request records.  It would be a nice feature to reduce over query time."

                        Remember that adding, say 'StatusField = No' into every existing Request by 'Replace Field Contents' would be exactly the same as simply adding one more request after the loop and making it an 'Omit' request for 'StatusField = Yes', for example, no matter how many requests there were.