3 Replies Latest reply on Jan 11, 2011 9:02 AM by philmodjunk

    Grabbing Find Criteria

    vChen

      Title

      Grabbing Find Criteria

      Post

      Hi,

      Is there is a way to get FM to capture the criteria that end users enter when they are in find mode?

      For example, if the end users want to find all the records for "12/1/2010...12/30/2010", how do I get that date range to print on the report when they see the results? Also (not sure if this is asking for too much), if possible, can it be formatted so that it does not have "..." and use "-" instead; so that it looks like "12/1/2010-12/30/2010".

      I hope this makes sense.

      Thanks!

        • 1. Re: Grabbing Find Criteria
          philmodjunk

          Best method I can think of, is to not do the finds directly on the local fields. Instead, define a group of global fields in a layout specifically designed for the user to enter find criteria. You then use a script that enters find mode and uses a series of Set Field steps that use the data in the global fields to enter the search criteria. Since the criteria was initially entered into global fields, it is then available to you to use in your report header.

          Heres a sample script that performs a date range find using two global date fields, gDate1 and gDate2:

          Enter Find Mode[]
          Set Field [YourTable::YourDateField ; YourTable::gDate1 & "..." & YourTable::gDate2]
          Set Error capture [on]
          Perform Find[]

          That's just to give you the idea of how this can be done. You can certainly create a more sophisticated script that produces different criteria based on whether there are dates entered in just one field or both.

          PS. With those two global fields, <<YourTable::gDate1>> - <<YourTable::gDate2>> could be used to put the date range in the header of your report.

          1 of 1 people found this helpful
          • 2. Re: Grabbing Find Criteria
            vChen

            Thank you!  I am always amazed at the speed and level of depth to your responses.

            I am a beginner at FM, so although I think I get the general idea of what you're going for, I'm not entirely sure how to implement it.  For starters, when you say define global fields, how do I do that?

            Also, I'm slightly confused by:

            Set Field [YourTable::YourDateField ; YourTable::gDate1 & "..." & YourTable::gDate2]

            I'm not familiar with Set Field[].  Is this setting MyTable::MyDateField to equal MyTable::gDate1 AND MyTable::gDate2? In other words, is it condensing the two global fields into one local field? 

            My next question would be in terms of layout, do I actually have two text boxes set up (one for gDate1 and one for gDate2) during the search? Otherwise, I'm confused on how there could be one text box that somehow contain two global fields.

            Lastly, I assume this script is prompted by a button that I would create.  This may seem like a silly question, but does Perfom Find[] apply to all fields that the end user wants search by?  In my db, I have several other criteria that end users can search by; not just date.  If I switch from using the default find button on the navigation bar to a customized script, will it also search by other criteria too?

            Thanks so much!

            • 3. Re: Grabbing Find Criteria
              philmodjunk

              when you say define global fields, how do I do that?

              After creating the field definition in Manage | Database | Fields, click the options button or just double click the row that defines this field. In the field options dialog that pops up, select the storage tab and you'll see a check box for specifying global storage. If you don't do this step for each field, the script example I have given won't work.

              Set Field

              Let's say your user enters this data: gDate1: 1/1/2011 gDate2: 1/31/2011

              Then the set field expression will enter: 1/1/2011...1/31/2011 into YourTable::YourDateField as find criteria--which is the date range type of search you described in your initial post.

              do I actually have two text boxes set up (one for gDate1 and one for gDate2) during the search?

              gDate1 and gDate2 are separate fields and both would be added to the same layout from which your user initiates the find by clicking a button to run the script.

              does Perfom Find[] apply to all fields that the end user wants search by?

              As written, this script set's up a find that only searches on one field, YourTable::YourDateField. If you need to search on other fields or use additional criteria the script would need to be modified. Remember that this is just an example to get you started. THere are many ways you can extend the basic concept. One way is to add additional global fields and then add additional set field steps to use them to create search criteria as well.

              There are many other ways you can customize this concept to fit your needs. You can create searches that use "or" logic instead of and.  (find all values in date range 1 or date range 2, records with "CA" in the state field or "NV"....) The script can perform an initial find and then use constrain found set to reduce the found set further... It can pause in find mode for the user to enter more criteria--though using global fields plus such a pause for input might be confusing for your user.

              1 of 1 people found this helpful