7 Replies Latest reply on Sep 27, 2013 6:56 PM by PaulWebb

    Quick Find - Numbers and Text Fields

    PaulWebb

      I am using the following script to perform quick finds. The field used is a global field (text). It works great so long as I am searching other text fields. Is there a way to set it up so it will also search number fields?

       

      FMPro 12 Adv

      FMS 12 Adv

       

      Perform Script [ “Allow User Abort” ]

      Perform Script [ “Set Error Capture” ]
      #
      Perform Quick Find [ GLOBALS::xquick_find ] If [ Get(LastError) = 401 ]

      Show Custom Dialog [ Title: "No " & LeftWords(Get(LayoutName); 1) & " Found!"; Message: "No " & LeftWords(Get(LayoutName); 1) & " was found!"; Default Button: “OK”, Commit: “Yes” ]

      Show All Records
      Else If
      [ Get(LastError) = 400 //These 2 steps added to show all records when no find criteria is entered (the xquick_find field is emptied) ]

      Show All Records End If

      Go to Field [ GLOBALS::xquick_find ]

       

        • 1. Re: Quick Find - Numbers and Text Fields
          PaulWebb

          Not sure this is the best way to resolve this but it works. Let me know if you have other ideas.

           

          I am using this on a list view. I duplicated the number field and made it text with an auto enter calculation of the number field I want to find. I then hung the new field off the edge of the layout and cleared its formatting and bumped the text over with an indent of 50. This way the field is on the layout but not visible. Works great but created a little clutter with adding the new field.

          • 2. Re: Quick Find - Numbers and Text Fields
            erolst

            Quick Find does search number fields. Make sure the field in question is "Included for Quick Find” in the Inspector.

            • 3. Re: Quick Find - Numbers and Text Fields
              PaulWebb

              If I set the global field I created to a number type then it works on number fields and not text fields. The workabound above is working well.

              • 4. Re: Quick Find - Numbers and Text Fields
                erolst

                Paul Webb wrote:

                 

                If I set the global field I created to a number type […]

                 

                That's not what I said in my post.

                 

                […] The workabound above is working well.

                 

                Well, then …sorry for interrupting.

                • 5. Re: Quick Find - Numbers and Text Fields
                  PaulWebb

                  Ok, so I completely misread your original post. Thought you said it does NOT search number fields.

                   

                  The field in question has the appropriate checkbox on but since the field types do not match it does not search the needed field.

                   

                  erolst wrote:

                   

                  Well, then …sorry for interrupting.

                  I didn't mean for that to come across nasty.

                  • 6. Re: Quick Find - Numbers and Text Fields
                    erolst

                    OK, never mind. Two things:

                     

                    1. Most of the times, FileMaker doesn't care about data type, at least not between numbers and strings – it's a sort of duck typing: it works, or it doesn't. It's up to the developer to make sure it does work.

                     

                    Try to multiply the contents of a text field; Filemaker does an implicit GetAsNumber() and gives it a shot, and there will be a result, though it might be 0.

                     

                    btw, in my sample file, change the type of the global to Number, then try to find text …

                     

                    2. I thought that maybe you expect a search in a number field to work like in a text field, but it doesn't. "Lazy" will find "A lazy", "the lazy" and "Lazybones", but 9 will only find 9, not 96, and not 69. And according to the FM12 Help, the Quick Find feature supports no operators except match phrase (""), so you can't find "lazy" by searching for "*azy", and you wouldn't find 9 in a calculated text version of 69 (if that even makes sense).

                     

                    Have a look at this, maybe it clears things up (it was instructional for me, anyways).

                    • 7. Re: Quick Find - Numbers and Text Fields
                      PaulWebb

                      Thanks. That makes sense. I appreciate the detail.