3 Replies Latest reply on Mar 26, 2013 10:03 AM by philmodjunk

    Auto-Complete feature question. Can the auto-complete options be set to occur anywhere in the field...

    AdamStrong

      Title

      Auto-Complete feature question. Can the auto-complete options be set to occur anywhere in the field entry?

      Post

       Hello,

      I have been using Filemaker for several months now and I am wondering if there is the ability to have the auto-complete feature, when typing in an entry where it autocompletes  when, that which is typed in is anywhere in the text of records in that field.

      For example. If I had a field with types of animals.

        Record 1:  Grey Whale.

        Record 2:  Blue Whale.

        Record 3:  Blue Dolphin.

        Record 4:  Bottle-nose Blue Dolphin.

       

      And I use the auto-complete feature and type "Blue", only records 2 and 3 would show up. However, I would like 2, 3 and 4 to show up instead as options to select. I understand I could make different fields and have layouts with each field so the user could search each field independently. But I want something that the user only has to type in one field to find. It seems if I want the program to give me all records in that field with "Blue" it would show records 2-4 but it will not have auto-complete options to choose from those 4 records. Thank you for your help!

      - Adam Strong

        • 1. Re: Auto-Complete feature question. Can the auto-complete options be set to occur anywhere in the field...
          philmodjunk

               The built in auto-complete feature does not work in this way. You might, with a fair amount of scripting and use of OnLayoutKeystroke or OnObjectModify, be able to create your own version of this feature that does.

          • 2. Re: Auto-Complete feature question. Can the auto-complete options be set to occur anywhere in the field...
            AdamStrong
             

            Thank you so much for your quick response. Could you elaborate a little more on what kind of code would be used on the OnLayoutKeystroke script trigger. Thanks again.

             

            - Adam Strong
            • 3. Re: Auto-Complete feature question. Can the auto-complete options be set to occur anywhere in the field...
              philmodjunk

                   It takes a pretty sophisticated script.

                   OnObjectKeystroke is actually the trigger I would use. It will be tripped every time the user presses a key while the cursor is in the field setup with this script trigger. The script could then use text to the left of the cursor to attempt a match to data in a related table. You'll first need to decide how far to the left of the cursor you want to go when checking for possible matches to data in the related table. If you go for every possible match, odds are that you will get unacceptable delays. If you only check every character in the current 1 or 2 words being entered, this may work reasonably well.

                   Other issues that complicate this:

                   You'd need a return separated list of values in your related table like this for the Grey Whale example you gave:

                   G
                   Gr
                   Gre
                   Grey
                   Grey   --there's a space character after the "y"
                   Grey W
                   Grey Wh

                   and so forth Such a list of values can be generated with a calculation, a custom function or a script. If you want, you can omit the first few values if you want this to take place only if several matching characters are first entered.

                   Once the script inserts the potential matching text, you'll need to devise a method that allows the user to quickly reject the added text if it is not what they wanted to enter. That may mean that you set the selection range to select the added text--the user then has to press an arrow key or click with the mouse to accept the text or perhaps the text is entered in color and if the user presses the delete key immediately after the insertion, all the added text is deleted, if the user presses any other key or exits the field, the text's color is changed to black...

                   As I warned, that makes for a pretty sophsiticated bit of scripting to make this happen with a distinct possibility that it might really slow down the rate at which text can be typed into the field.

                   A possible, simpler and faster alternative might be to display these terms in a list such that clicking one inserts the displayed text at the current cursor position.