14 Replies Latest reply on May 6, 2016 11:26 AM by wendy

    Add a QuickFind Field to a Form

    steve4640

      Title

      Add a QuickFind Field to a Form

      Post

      Hi, I'd like to add a single text field to a form, then have the user enter a term in that field, then use QuickFind to find the records. I realize there's a QuickFind field at the top of the Browse form, but my non-tech-savvy users are not seeing that and want something more obvious on the form itself. Is there any way to do that? Thanks!

        • 1. Re: Add a QuickFind Field to a Form
          SteveMartino

          Just add a global field.  You can put a button next to it to perform a script.  The script will gather the field info into a local variable, then use the script step Perform Quick Find based on the variable.

          To enhance it further you can use a script trigger to perform the find after a user hits return or enter, and reset the  field to blank.  And you can enhance it even further, and further

          • 2. Re: Add a QuickFind Field to a Form
            philmodjunk

            No need for the variable, Steve. The quick find step can simply refer to the global field.

            • 3. Re: Add a QuickFind Field to a Form
              steve4640

              Great, thanks! I got something working. More progress than I expected by now. However, it looks like I need to have all the other fields that are being searched also on the form, but in the ideal world, I'd like to have just the single global field on the form. Is this a case where I'd need to hide the other fields using a calculation?

              • 4. Re: Add a QuickFind Field to a Form
                philmodjunk

                Or maybe it would be simpler to perform a regular find instead of the quick find?

                • 5. Re: Add a QuickFind Field to a Form
                  steve4640

                  That was my first idea, too, but my users want one field that searches everything. The regular find confuses them. This is a very simple app with no user interaction other than to search one field to call up the records they want.

                  • 6. Re: Add a QuickFind Field to a Form
                    philmodjunk

                    But your script can perform a "regular find that searches everything". The user just fills in the data in the global field and the script takes it from there. The advantage here is that you do not need to have all the fields to be searched on the current layout.

                    For examples of scripted finds that work from criteria entered by the user into a global field see: Scripted Find Examples

                    • 7. Re: Add a QuickFind Field to a Form
                      steve4640

                      Thanks! This sounds exactly like what they want-looking forward to giving it a try.

                      • 8. Re: Add a QuickFind Field to a Form
                        steve4640

                        This works great! However, is there a way to add more fields to the search? I have 4 fields that need to be searched this way, First, Last, Contract and Summary. Thanks!

                         

                        • 9. Re: Add a QuickFind Field to a Form
                          steve4640

                          Here's the simple example script I set up in reference to the previous comment. It works great, I just would like to add the other three fields that would also be searched. Thanks!

                          http://www.screencast.com/t/UlRMJeISX

                           

                          • 10. Re: Add a QuickFind Field to a Form
                            SteveMartino

                            I would do an "OR" search with steps like this:

                            Set Error Capture [On]
                            Enter Find Mode [ ]

                            Set Field [Table::FirstNameField; global field]

                            New Record Request //for an "OR" search

                            Set Field [Table::LastNameField: global field]

                            New Record Request //for an "OR" search

                            Set Field [Table::ContractField: global field]

                            New Record Request //for an "OR" search

                            Set Field [Table::SummaryField: global field]

                            Perform Find [ ]

                            If [Get (LastError) = 401] //No records found, but you could use just Get(LastError) for any error

                            Show Custom Dialog.........etc., etc

                            • 11. Re: Add a QuickFind Field to a Form
                              philmodjunk

                              Adding more fields simply means that you add more set field steps. But there's s key detail missing in your question:

                              Do you want to find records that match the criteria in Field1 AND Field2 AND Field3? or do you want to find records matching the criteria in field 1 OR field 2 OR field 3?

                              Both are possible. The first requires putting all the criteria in a single find request. The second requires generating a new request for each criterion. You should find examples of both approaches as well as methods using extend and constrain found set that can also produce the same results.

                              • 12. Re: Add a QuickFind Field to a Form
                                steve4640

                                Thanks for the replies! This would be an AND search, i.e., trying to do the same thing you do with Quick Find (find all records containing all the terms entered in the search field). I found an example in the forum how to put all criteria in a single find request on a form (my example is in the screen grab), but it's still not quite what we need:

                                 

                                 

                                 

                                 

                                http://www.screencast.com/t/UAM7OxeNZt

                                My example works only if the terms are all in the same field. We have terms in different fields that have to be included in the find.

                                I appreciate all the help-this is my first foray into a Find situation this involved, so trying to get up to speed.

                                 

                                 

                                 

                                 

                                 

                                • 13. Re: Add a QuickFind Field to a Form
                                  philmodjunk

                                  Use Steve's example. What you want is not an AND search but an OR search.

                                  You are searching for records that have the search text in

                                  field 1 Or in field 2 or in Field 3...

                                  • 14. Re: Add a QuickFind Field to a Form
                                    wendy

                                    I thought I would post how I created a quickfind field that appears to be intuitive for our users.

                                     

                                    This is what I did:

                                    Created the global Quickfind field;

                                    Gave it rounded corners and a white background;

                                    Built a magnifying glass using Filemaker drawing tools (circle and line grouped) and placed it just inside the field (screen capture attached);

                                    Set field padding on the left to 15, added an inner drop shadow with a blur of one;

                                    On the Inspector/Data tab, in the "go to next object using" area, checked Return and Enter;

                                    Added two scripts and script triggers:

                                      OnObjectEnter:  A "Quickfind_Clear" script that just sets the field to ""

                                      OnObjectSave (OnObjectExit should also work): A "Quickfind_Find" script:

                                      If (not IsEmpty (YourTable::YourQFfield)

                                          Perform Quick Find (YourTable::YourQFfield)

                                      End If

                                      Exit Script [Result:  0]      (false)            (Thanks to Bruce Herbach, 2/15/2015, "Exit Field Focus" thread)

                                    I already had an OnLastWindowClose script for the file (we have a multi-file database). I added a step to clear the QuickFind field. Could also add a trigger when the user leaves the layout.

                                    -----

                                    Resulting behavior:

                                    When I click in the field, the magnifying glass disappears and a blinking cursor shows.

                                    I type in my search criteria and press the Enter/Return key on the keyboard.

                                    It finds the records and exits the field.

                                    The value I searched for remains in the field until I click in it again, at which point it clears for a new entry.

                                    Right now if there is no match for the search criteria, it just shows the Filemaker default (No records match...) dialog, and leaves the me with the existing found set.

                                     

                                    Works for me in Filemaker 13 on Mac OS 10.9.5 and Windows 7 Enterprise. I don't know about mobile.

                                     

                                    I ran into a bit of a bummer when I discovered the QuickFind step doesn't support asterisk searches (e.g. searching for C1-194 brought up the C1-194 record, but searching for 194 did not bring up all records with 194), but it is still useful.QuickFindfield.jpg