7 Replies Latest reply on May 19, 2014 4:25 PM by philmodjunk

    Searching records based on fields (via check box)

    MartinKim

      Title

      Searching records based on fields (via check box)

      Post

           Hi,

           I am trying to create a db where you can search for certain records based on the existing fields (Title, Author, and Keywords). I have written a script that can look for one field only, and it works. But I would like to incorporate the check box and enable the user to search for records using one or more fields by using the check box. 
           ...But this is where I am stuck. 
           I created a gSearchField that takes in the input value that searches for one field. But I do not know how to include more than one fields using the check box. 
           Below is the design of my database so far.

           Also, is there a way of doing search by hitting the enter button? Whenever I hit enter, it does not do the search but expands the search box instead. So I have to just click out of the box in order to see the results.

           Thanks a lot! 

           Martin

      q.png

        • 1. Re: Searching records based on fields (via check box)
          philmodjunk

               Exactly where would the check box go on your layout and what values would you put in the value list for that check box?

               Your layout shows a typical search portal, where a relationship and/or portal filter that incorporates the search field control what matching records appear in the portal, but then you show a script that enters find mode and performs a find--which is not a method that you can use to find records in a portal, it would find records in your layout's found set.

               So a bit more info on what you are trying to set up would help us to help you.

          • 2. Re: Searching records based on fields (via check box)
            MartinKim

                 Oh, right. Sorry.
                 So the picture being uploaded right now is the main database, where you add and edit information. And by clicking on "Find" button, it directs you to the layout that I uploaded initially; and you search Keywords on the box at the top in the first image. And the check box (3 fields) is on the top left corner. 

                 Does this clarify? Sorry for the confusion. 

                 Martin

            • 3. Re: Searching records based on fields (via check box)
              philmodjunk

                   That helps, but why do you have a portal on that layout? How will that be used?

              • 4. Re: Searching records based on fields (via check box)
                MartinKim

                     The portal is used to display the pictures, which are categorized, and related to the main database.
                     The only things that will be needed for the search are the Title, Author, and Keywords, which I want to add to the search system by using the check box. Is there a way to search for records using the Title, Author, and Keywords by using the check box?

                     Martin

                • 5. Re: Searching records based on fields (via check box)
                  philmodjunk

                       That's not the portal that I am asking about. In your initial screen shot, there's a portal with columns labeled "Patient ID", "Author", "Title", "Keywords".

                       What is the purpose of that portal?

                       The reason that I am focusing on that detail is that there are two commonly used methods for providing script assisted search tools for a database. One method uses a "search portal" and this portal looks set up to be such a portal. In this scenario, you enter search text in the field(s) above the portal and the portal updates to list matching records. Clicking a button in the portal row then selects a specific record to work with from the list of matching records.

                       The other method uses a scripted find from data entered into global fields. Your script example in the same screen shot appears to be just such a scripted find.

                       But you normally would not use both methods from the same layout design and thus I am trying to determine from what layout design you want to have people use when doing this search of your database.

                  • 6. Re: Searching records based on fields (via check box)
                    MartinKim

                         Ohh I see. Yes, oddly, you are correct, and both methods are used in the database. The second method that you described is used on the second screenshot, where if you click "Find", it directs you to the layout of the first screenshot. Then, I used the filter portal search method that you demonstrated on a forum post long time ago to refresh and filter the records on the portal as you type on the global search field. 
                         Now that I come to think of it, the script is not necessary.. as I just need to have the "Find" button direct me to the layout of the first screenshot, and the search portal is set up to do the search.

                         So I guess the check box search method that I am asking on the forum is part of the first method that you described (search portal). 

                         Sorry for the confusion / mistake!

                    • 7. Re: Searching records based on fields (via check box)
                      philmodjunk

                           Title, Author and Keywords can be three check box values for a single field or three separate fields. Both can be set up for use with your portal filter expression, but which option you chose will change how you write that filter expression.

                           Say these are three different fields that enter a "1" if they are clicked. (Size the field to be just wide enough to show the check box--hiding the "1" and type in the text shown as layout text.)

                           If ( LayoutTable::TitleCheckBox ; PatternCount ( PortalTable::TitleField ; SearchField ) ) OR
                           If ( LayoutTable::AuthorCheckBox ; PatternCount ( PortalTable::AuthorField ; SearchField ) ) OR
                           If ( LayoutTable::KeywordsCheckBox ; PatternCount ( PortalTable::KeywordsField ; SearchField ) )

                           Using a single field with 3 check box values:

                           If ( Not IsEmpty ( FilterValues ( LayoutTable::CheckboxField ; "Title" ) ) ; PatternCount ( PortalTable::TitleField ; SearchField ) ) OR
                           If ( Not IsEmpty ( FilterValues ( LayoutTable::CheckboxField ; "Author" ) ) ; PatternCount ( PortalTable::AuthorField ; SearchField ) ) OR
                           If ( Not IsEmpty ( FilterValues ( LayoutTable::CheckboxField ; "Keywords" ) ) ; PatternCount ( PortalTable::KeywordsField ; SearchField ) )

                           If you used the left function instead of patterncount, the same patter holds, it's just the expression to the right of the ; in each line that needs to be changed.