11 Replies Latest reply on Dec 20, 2011 10:43 AM by jbante

    Record X of X

    arthursc

      I would like to display a summary at the bottom of may layouts list Record No: X of X.

       

      I think I know what the basis of this is and that is to use a Get Function.

       

      I cannot find anywhere where it gives some sort of step by step instruction on how to do this.

       

      Could someone help me please?

       

      Regards

      Colin

        • 1. Re: Record X of X
          Kantala

          Hi Colin

           

           

          How about this (in a calculation field or web viewer with data url or merge variable)

           

          Let ( [

           

           

          fc = Get (FoundCount);

          tc = Get (TotalRecordCount);

          ];

           

          "Record No: " & Get (RecordNumber) & " of " & fc & Case (fc ≠ tc; "; " & tc & " total")

           

           

          )

           

           

          This will display "Record No: X of X" with the addition of "; XX total" if there are other records not in the current found set.

           

          Hope this helps

           

          Matt

          • 2. Re: Record X of X
            arthursc

            Thanks Matt,

             

            AM I correct in assuming that I have to create a field in my table and then create the above as a calculation for that field? If so do i have to do this for every table for each of my layouts?

             

            Regards

            Colin

            • 3. Re: Record X of X
              paulspafford

              Hey Colin,

               

              There are a couple posts on my blog that take you through this step-by-step.

               

              This one uses a calculation field, but I like Matt's calculation better than the one I use:

              http://fmlayoutmode.com/wp/?p=1437

               

              This one uses a Web viewer, and means you don't have to create a field in each table:

              http://fmlayoutmode.com/wp/?p=1572

               

               

              Paul

               

               

               

              --

              Paul Spafford

              FileMaker Database Superhero,

              Spafford Data Solutions

               

              Tel: 613 838 9956

              www.paulspafford.com

              www.ottawafilemakerdeveloper.com

              www.fmlayoutmode.com

              www.fmscripts.com

               

              FileMaker User Group in Ottawa:

              www.meetup.com/fudgeo

              • 4. Re: Record X of X
                BruceHerbach

                Colin,

                 

                If you are using a script to change records, you can use a set variable

                statement and put the text string into a global variable and put a merge

                variable at the correct location on the screen.

                 

                If there isn't a script you can add an OnRecordload script trigger and

                create a script to set the variable.

                 

                Hope this helps

                Bruce Herbach

                • 5. Re: Record X of X
                  Kantala

                  Hi Colin

                   

                  You could create a field in every table if you so wished.  You could copy / paste it between tables as it doesn't reference any fields. 

                   

                  Or you can use a web viewer to display it and so avoid any fields at all (that's what I do).  Using this method makes it easy to adjust to the context of your layout too, so you can have "Job No: X of X" or "Contact No: X of X".  Paul's link shows you how to use a web viewer to display a data url (by the way I'm a big fan Paul, keep up the good work!).  I use a slightly different set of custom functions that Matt Petrowsky wrote (can't find the link now, but let me know if you're interested and I'll keep digging) that allows me to specify CSS seperately, so I can style the html to fit the layout. 

                   

                  Or you could define a merge variable to display the information, but this is probably not worth the effort, since you'd need to trigger it to change with every change in the found set...

                   

                  Cheers

                   

                   

                  Matt

                  • 6. Re: Record X of X
                    jbante

                    Actually, you can use a merge variable without a script. I prefer doing it this way over the webviewer technique because it gives me FileMaker-native control of the text formatting. You create two merge variable text objects: <<$calculation>> and <<$recordPosition>>. <<$recordPosition>> must be above <<$calculation>> in the layout object layering for this to work correctly. (This doesn't mean it has to be directly on top of <<$calculation>>, just further forward.) On the <<$calculation>> object, you add a conditional format based on this calculation:

                     

                    Let ( [

                    $recordPosition = /* record position calculation of your choice */;

                    $calculation = ""

                    ];

                    False

                    )

                     

                    This will set the merge variable for you without the need for a script, and you have full control over how it looks without having to know CSS. As an added bonus, it works correctly when you have multiple windows open because it uses $local rather than $$global variables — the scripted version would have to use $$global variables, and so would have to show one record position for all windows, even if two windows are on different records.

                    • 7. Re: Record X of X
                      jormond

                      If you choose to go with a Merge Variable, you can use a Conditional Formatting ( couple posts here that explain it briefly )trick to make it refresh with every redraw (that way it's always correct).  I either use the Web Viewer, or a Merge Variable. So no fields...just depends on the situation if I use the Web Viewer or Merge Variable.

                       

                      Edit:  Great tip Jeremy.  We must have been typing at the same time.  hehe

                       

                      Message was edited by: jormond

                      • 8. Re: Record X of X
                        Kantala

                        Very nice, thanks for the tip.  Didn't realise you could local variables in this way.

                        • 9. Re: Record X of X
                          jormond

                          Yeah it's a cool tip.  I came across it totally by accident one day when I was testing something else.  Another nice thing about it, it doesn't clash with variables in scripts.  If a script sets the $variable with the same name, the variable assumes the value from the script until the end of the script.  Once the script is done, the $variable reverts back to what it was set at before the script.

                          • 10. Re: Record X of X
                            arthursc

                            Hi jbante,

                             

                            Thank you for that. I have tried as you have explained but my knowledge is limited.

                             

                            Are you able to provide a sample file for me?

                             

                            Regards

                            ArthursC

                            • 11. Re: Record X of X
                              jbante

                              I don't have time at this moment to put together an example file, but here's a demo I put out that makes very heavy use of the technique: http://fmscripts.com/?p=26