13 Replies Latest reply on Dec 4, 2013 2:29 PM by philmodjunk

    Setup Button to go to a specific record?

    AbdoulBaldé

      Title

      Setup Button to go to a specific record?

      Post

           Hi , 

            

           I have 2 related tables:

           Floor Levels:

           - Level_ID (PK)

           - Level_Name

            

           Rooms & Capacities

           - Room_ID (PK)

           - Room_Name

           - Room_Capacity

           - Level_ID (FK)

            

           I have linked the table and created a drop down to select the floor level as well as a portal to display the rooms for each floor level. That works fine. 

           NOW, I would like to add buttons on my Layout ( "1", "2" , "3", 4,...) corresponding to the floor level. I think I need to select the go to record script as button setup but then I am stuck at the calculation step. How can I link button "1" to Level 1? 

            

           Many Thanks. This forum is a gold mine and without it ... :(

        • 1. Re: Setup Button to go to a specific record?
          philmodjunk

               Are you on a layout based on Floor Levels?

               is 1, 2 , 3, 4... the name of the level or the ID?

               Does/Will your table contain data on more than one building and thus have more than one "level 1"?

          • 2. Re: Setup Button to go to a specific record?
            AbdoulBaldé

                 - Yes The Layout is based on Floor levels Table. 

                 - 1, 2, 3.. is the ID (For Floor Level_ID = 1 , Floor Level_Name = Level 1)

                 - No Floor Level_ID is a unique key I used even though Floor Level_Name is also a unique key. There is only ONE "Level 1"

                  

                 Thanks

            • 3. Re: Setup Button to go to a specific record?
              philmodjunk

                   Then you can set up all your buttons to perform the same script but pass either the ID or the name of the level as a script parameter. The script can use the script parameter to perform a find for that level record:

                   Enter Find Mode []
                   Set Field [Floor Levels::Level ID ; Get ( ScriptParameter ) ]
                   Set Error Capture [on]
                   Perform Find []
                   If [Not Get ( FoundCount ) ]
                      Show All Records
                      Show Custom Dialog ["No such level exists"]
                   End If

              • 4. Re: Setup Button to go to a specific record?
                AbdoulBaldé

                     Thanks. I tried but it does not go to the correct record level. I am also wondering whether I need the Custom Dialog since the button already appear on the Layout. There is no search to do. What I am looking for is a way to go Level record "1" when clicking on button "1". 

                     I tried to use the script I am using for the floor selection drop down which works fine: 

                     Floor selection drop down script:

                     Enter Find Mode ()

                     Set Error Capture (On)

                     Set Field ( Floor Levels::Floor Level_Name; _gf_Floor Level Selection)

                     Perform Find ()

                     Commit record

                      

                     Could you please advise? 

                • 5. Re: Setup Button to go to a specific record?
                  philmodjunk

                       You have a different button for each level, correct?

                       Did you set up each button to pass the correct value for the level as a script parameter? Each button should pass a different value.

                  • 6. Re: Setup Button to go to a specific record?
                    AbdoulBaldé

                         Yes I have a different button for each level. 

                         I don't understand the "pass a different value" concept.  Please see screenshot. Currently clicking on button 1 clears the data from the drop dow list on top of the buttons and there the Floor Level summary displayed in the tab panel. 

                          

                    • 7. Re: Setup Button to go to a specific record?
                      philmodjunk

                           When you open button setup for your button and click specify, you get a dialog box where there is a place to enter an "option script parameter" This allows you to pass a different value to this script for each button as you can specify a different value for each of your buttons.

                           The set field step should just be:

                           Set Field [Floor Levels::_kp_Floor Level_ID ; Get ( ScriptParameter ) ]

                           The "= 1" should not be there.

                           But isn't your layout set up with a drop down list for selecting a level and then you see the rooms listed in the portal? That design seems counter to what you now want to do with your buttons.

                      • 8. Re: Setup Button to go to a specific record?
                        AbdoulBaldé

                             Yes but the buttons will alow to use one less click to access the Floor level information. This is why I would like to implement the button. Regarding the fact that I have a button for each level, should I replace the part of the script from "If" (...) to "End if" by Omit records as I don't want the dialog box to appear? 

                              

                             Also: In the optional script parameter box I entered ==> Floor Levels::_kp_Floor Level_ID = 1. For button "1" but it does not work either...

                              

                        • 9. Re: Setup Button to go to a specific record?
                          philmodjunk

                               You would just enter the literal value. If the ID for the level is 1 for that button, just enter a 1.

                               Floor Levels::_kp_Floor Level_ID = 1

                               is a boolean expression. If true, it will pass a 1 for TRUE on to the script. If not, it will pass a 0 for FALSE.

                               But if you are using a portal to display the rooms, this is the wrong script to use as your script can simply set a value in the drop down list field with each mouse click instead of performing a find.

                          • 10. Re: Setup Button to go to a specific record?
                            AbdoulBaldé

                                 Thanks. It works since once the button is clicked, it sets the value in the drop down which sets the rooms & the Floor summary via the portal. If you have another option, maybe a simpler one I would really appreciate. 

                                 Also, I am displaying the details (rooms) /(Floor summary) in a portal. Is there a way to adapt the specified fields for the Layout to the content size instead of having a set field size? 

                                  

                                 MANY THANKS

                            • 11. Re: Setup Button to go to a specific record?
                              philmodjunk
                                   

                                        If you have another option, maybe a simpler one I would really appreciate.

                                   There are two options. The one you now have working where a drop down list field controls what related records appear in a portal, and setting up a portal that is not controlled by a drop down list but is instead based on the Levels::LevelID to Rooms::LevelID relationship. This was what I first had in mind until I noticed/remembered that you had already set this up with the drop down list controlled portal. In this second method, you change to a different record for a different level and see the rooms for that level appear in the portal on that record.

                                   To the user, there is little if any visible difference with the two approaches. Either way, they click a button and get a list of rooms in a portal.

                                   

                                        Is there a way to adapt the specified fields for the Layout to the content size instead of having a set field size?

                                   There are some very limited options. If you do not need to edit the field, you can try using the text tool to add a text object and then use the insert menu to insert the field as a merge field into the text object. Merge fields will expand and contract within the limits of the text object so this can provide a limited ability to adjust field size to fit the data. This is most often used to create a kind of "form letter" block of text where data is inserted into the midst of layout text to produce a smoothly flowing block of text.

                                   If you don't use a portal, (And your list of rooms does not have to be listed in a portal like you currently have in place) and need this adjustment for printed or saved as PDF output, you can set fields to slide up/left and to resize the enclosing part.

                                   Key facts about sliding layout objects:

                                     
                              1.           It's only visible in preview mode and when you print/save as PDF...
                              2.      
                              3.           Sliding fields will shrink but not expand.
                              4.      
                              5.           All layout objects below and in the same layout part as the slide/resize field need to also be set to slide up and resize.
                              6.      
                              7.           Objects in headers and footers will not slide.
                              8.      
                              9.           Portals will shrink/slide to fit the number of rows of records, but fields within the portal row will not shrink/slide.
                              10.      
                              11.           Fields will slide up only if Top alignment is specified for it and will slide left only if Left alignment is specified.
                              12.      
                              13.           Consistent side borders are difficult to achieve with sliding fields.
                              • 12. Re: Setup Button to go to a specific record?
                                AbdoulBaldé
                                and setting up a portal that is not controlled by a drop down list but is instead based on the Levels::LevelID to Rooms::LevelID relationship. This was what I first had in mind until I noticed/remembered that you had already set this up with the drop down list controlled portal. In this second method, you change to a different record for a different level and see the rooms for that level appear in the portal on that record.
                                           
                                Could you please explain this method further. How can you navigate from 1 level to another ? I am really interested in knowing how to use a portal with buttons instead of drop down list where each button would display the related records in the portal when you click it.?
                                      
                                I understand that the script you helped me with (Floor Level Navigation with the buttons) has to be slightly modified. 
                                Current script used in buttons:
                                          Enter Find Mode []
                                     Set Field [Floor Levels::Level ID ; Get ( ScriptParameter ) ]
                                     Set Error Capture [on]
                                     Perform Find []
                                     If [Not Get ( FoundCount ) ]
                                        Show All Records
                                        Show Custom Dialog ["No such level exists"]
                                     End If      
                                           
                                           
                                     ==> With optional script parameter set for each button.
                                      
                                     THANKS
                                • 13. Re: Setup Button to go to a specific record?
                                  philmodjunk

                                       Presumably you have this relationship:

                                       Levels::__pkLevelID = Rooms::_fkLevelID

                                       but with your names instead of mine.

                                       With this relationship, you can put a portal to Rooms on the Levels layout. Then buttons that move you to different records move you to records with different Level ID values and you see a different group of records in the portal each time that you change records.