8 Replies Latest reply on May 26, 2017 7:16 AM by tolson

    Hiding a field based on a calculation

    tolson

      I'm having a tough time figuring out how to hide a field with my current design

       

      I'm working with a trivia dB that has 10 different categories. Depending on which "round" the user is on, five of these categories will be available to the user. To access the category, they click on a button and view the records. Once they've viewed all the records, they exit back to the switchboard where they will have to access the remaining 4 categories until they have viewed all questions.

       

      Everything is working fine, except that I now want to hide the buttons wherein the user has viewed the data. In other words, if the 5 categories are "Sports, Math, Nature, Current Events & Music", once they have viewed all of the "sports" questions, that button will no longer be visible, preventing the user from reviewing the "sports" information set again.

       

      Here's the underlying table:

       

      ID is the key field, Question is obvious, Category is one of the 10 subjects. "Era, Year, Grade, Sub Category" are all used for sort specs, "Round" represents which stage of questions they are viewing (they can't view anything in round 2 until they view all of round 1), "Used" gives me a yes or no of  the records have been viewed already. "Found Records" was put there as an idea I had earlier, but decided against using it. I actually need to delete that field.

       

      Initially what I wanted to do was simply enter ([Category] = "Sports" ) & ([Used] ="6") into the "hide object when" field, but it doesn't look like I can use a found set to evaluate things. I need to rethink and my brain is stuck.

       

      I come from the world of Access and old habits seem to have worked me into a corner.

        • 1. Re: Hiding a field based on a calculation
          TomHays

          It sounds like you want the button to always disappear after it has been clicked in that round.

           

          In the script for the button action have a script step

          Set Variable [$$button_clicked_Sports;  Value:1]

           

          For your "Hide object when" calculation you can use:

          $$button_clicked_Sports

           

          Create similar global script variables for each button.

           

          Reset these variables back to empty when you want the buttons to be visible again.

           

           

          -Tom

          • 2. Re: Hiding a field based on a calculation
            tolson

            Well I have it programmed right now so if the user just answers "x" amount of questions and exits back to the main switchboard to dive into another category, they can. When they re-enter, as long as there are still questions to view, they will pick up where they left off, in other words they won't have to scroll back through already viewed data. So, no, the button can only be made invisible when all the questions have been viewed.

            • 3. Re: Hiding a field based on a calculation
              TomHays

              The nice thing about the global script variables is that you can assign them from any context.  Whenever you determiine in your logic that the user has satisfied answering these questions, then set that variable.

               

              You can even make it a counter and check to see if that variable has exceeded the threshold number (or counted down to zero).

               

              "as long as there are still questions to view" seems to be your determining criterion.  The script that brings the user to the main switchboard from the question viewing section should be able to decide if the button needs to be viewed on the switchboard assign a value to the global script variable before the switchboard is displayed.

               

              -Tom

              • 4. Re: Hiding a field based on a calculation
                siplus

                thinking multi user, for each user you should have a list in a text field containing the PK's of viewed questions.

                 

                You hide stuff based upon PatternCount(UserQuestionAlreadyViewedListID, currentRecordID).

                 

                Don't see the problem.

                • 5. Re: Hiding a field based on a calculation
                  tolson

                  Tom:

                   

                  The counter concept is something I employed, just not sure if it's applicable. Each time the user is in a set of questions (6 questions) and they advance to the next question, the "used" field is changed from "0" to "1". When the user reaches a total of "6" in this found set they are automatically exited back to the round switchboard. This is done with If Get( Foundcount ) = Get( RecordCount ) close window (currentwindow).  My intention was that once the Foundcount = Recordcount for THIS set was achieved the button would disappear as the user was returned to the round switchboard, but I'm missing something.

                  • 6. Re: Hiding a field based on a calculation
                    TomHays

                    If (your test to see when you are done)

                    close window (currentwindow)

                    Set Variable [$$button_done_Sports;  Value:1]

                    end if

                     

                    This assumes that you know which button to disable.

                    The Sports button has $$button_done_Sports as its Hide calculation.

                     

                    Or if you want to be more generic you can do something like

                     

                    If (your test to see when you are done)

                    Set Variable [$$buttons_done;  Value:List($$buttons_done; MyTable::Category)]

                    close window (currentwindow)

                    end if

                     

                    Then $$buttons_done will contain a list of the categories that you have finished.

                    The Hide calculation for the Sports button would be something like

                    not Empty(FilterValues($$buttons_done; "Sports"))

                     

                     

                    Your stated test of Get(FoundCount) = Get(RecordCount) doesn't make sense to me since there is no Get(RecordCount) function.

                     

                    Do you need assistance on the logic of detecting when the user has responded to these questions?

                     

                    -Tom

                    • 7. Re: Hiding a field based on a calculation
                      tolson

                      Tom, you are correct, the formula is If [Get (RecordNumber) = Get (FoundCount)] Then Close Window

                      • 8. Re: Hiding a field based on a calculation
                        tolson

                        The test to find out if the button should be inactive is the results of a foundset. If Category = 1 and Used = 6 then...This seems more like a script but the "hide results" or "conditional formatting" are expressed as calculations.  I think that's where I'm perceptually running into a wall.