12 Replies Latest reply on Aug 10, 2016 9:11 AM by jdevans

    Page "number" of page "count"



      Page "number" of page "count"


           I would like to have a "count" of the report pages.... and see Page 1 of 3, page 2of 3, etc on the header or footer of the report.

           re:  Page Numbering Problem (Starts at Zero)  thread      Page Numbering Problem (Starts at Zero)

           I am using FM 12 also, but I am not having the problem described, (the page number beginning at zero).  I am saving the reports to .pdf and printing them later, I am not sending the report directly to the printer from FM, not sure if that makes any difference or not.   

           I have some questions regarding the steps suggested by the developer

                        To display the total number of pages on each page of a printed document using a script, follow these steps:

                          1.In Manage Database, define a number field titled Page Count. Click Options (or double-click the field name).

                          Click the Storage tab, then select Use global storage (one value for all records).     

           I created the global number field.  I am confused at the global storage here. Doesn't the global field capture data from another field?  How does the page number get entered into the global storage field? Should there be a page count calculation field or something the global field relates to? What am I missing?

            2.On your print layout, type "Page ## of <<Page Count>>" (without the quotes) in the header or footer.

       (## prints the current page number, <<Page Count>> is a merge field).


      Typing (into a TEXT Box) without the quotes    "Page {{PageNumber}} of <<Page Count>>   

      Was I supposed to type into a "text box" or is there some other way to place this in the layout?

      Since  ## isn't supported in FM12, using  "{{PageNumber}}" (without the quotes) should work, no?

      It  shows    "Page  1 of                 "        (without the quotes)     and the merge field is blank.  

       << field name >> is a merge field and typing this within a text box places that field in the text box, so the text box functions? 


      3.Create a script that has these steps:    

      4.SNIP      could anyone elaborate on this?  Not the faintest idea of what this entails.....

      (private note to Alan: I did not use the "s" word :)


        • 1. Re: Page "number" of page "count"

               Create a Global field Page Count.

               Then you would have a script to get the number of pages. 

               Freeze WIndow
               Enter Preview Mode[]
               Go to Record/Request/Page[Last]
               Set Field [Page Count; Get(PageNumber)]
               Enter Browse Mode[]




          1 of 1 people found this helpful
          • 2. Re: Page "number" of page "count"

                 Global storage means that the field will store a single value over all the records in the table. You might have 2000 records, but the field will contain the same value no matter which record is current. This means the script S Chamble has recomended can be used to determine the page number of the last page of your report and store it in the global field.

                 FileMaker 11 and older used ## as layout text that will display the page number. FileMaker 12 uses the new text in curly brackets that you have posted for the same purpose.

            • 3. Re: Page "number" of page "count"
                        Sigh.  Trouble with the script. And (assuming I get that far...) where do I apply the script?

                             Thanks for the global field explanation.

                             Set Field [Page Count; Get(PageNumber)]

                             an error message keeps popping up.   Maybe some FM 12 requirement?

                             About the {{PageNumber}}  or ##    Is this a field or some function related the report?   In the other thread David posted a link to an article from six fried rice ... the script there applied to an much earlier version of FM and was six fried rice miles long.... so I am more confused than I was to start with.  




              • 4. Re: Page "number" of page "count"

                     In 12 use {{PageNumber}} to display the page number, which is also on the Insert menu as Insert Page Number. 

                     You run the script before you display your report so it can get the total number of pages.  This can be part of a button to display/print your report.

                     I have a sample app I group all the items in the footer so it would be easier to move all objects at one time.  You may have to adjust the with of the PageNumber and Page Count depending on the number of pages you will have.  I set to .25 width. 

                     Sample App.


                     You can not run the script direct from the layout.  In the sample app you have to click on the script from the menu to run the script.  You will have to script your preview / print button to handle getting the total page count.  You can hide the print button so it does not print by using hide when printing from the inspector.  The sample app is very basic to give you an idea. 


                • 5. Re: Page "number" of page "count"

                       Thank you S Chamblee!  I am almost there. The issue now is that the report layout is set for 6 pages, and  because of the numerous text fields, they are all set to slide up and do so appropriately. As it is now, when I save to .pdf, only the actual number of pages are saved, which is what I want. I inserted the script button you created and it works but it counts all 6 pages and that is what gets saved as a .pdf when I hit that button. Can these scripts be combined and the order of the steps be changed so that the report is able to slide, count the remaining pages and then .pdf? 

                  • 6. Re: Page "number" of page "count"

                         Yes you can combined the scripts.   When the script (I created) goes into preview mode it should be a preview of the same report that is being saved as pdf.  You might want to take out the "Freeze Window" so you can follow the script.  You would want to go to your report layout before you enter preview mode,  so you get the same report.  

                    • 7. Re: Page "number" of page "count"

                           But I don't have your script working properly yet. It counts all 6 pages of the layout, I need it to count only the pages have text within the body.  How do I write the script to subtract the blank pages?

                      • 8. Re: Page "number" of page "count"

                             Enter preview mode before counting the pages.

                        • 9. Re: Page "number" of page "count"

                               S Chamblee's script had "enter preview mode" within it as a step.  If I enter preview mode before I hit the button with the script, the button is not visible.

                               When I hit the 'save tp .pdf" botton, the report is saved with the actual number of pages but the count is still   1 of 6, 2 of 6, etc.      ???? 

                          • 10. Re: Page "number" of page "count"

                                 The button you click should perform a script that starts with Enter Preview Mode[]

                                 Your script cannot correctly count the pages if the window is not in preview mode.

                            • 11. Re: Page "number" of page "count"

                                   Ahh... I took off "freeze window" and it worked. I then created a new script combining those 2 scripts and Wah Lah! Works like a Charm! I'm going to add this to all of my reports!

                                   The sample DBs are a great help...  Many thanks to you both.

                              • 12. Re: Page "number" of page "count"

                                This solves a problem I have on several layouts. Thanks for posting!!