12 Replies Latest reply on Jun 28, 2012 11:11 AM by philmodjunk

    Page X of Y ... again

    EricaHeath

      Title

      Page X of Y ... again

      Post

      I need to put "Page X of Y" on an agenda report.  (And on other things but if I can do it here I can generalize.)  I keep trying to do it and give up.  This time I will prevail! 

      I have followed answer ID 3629 on the FM support page.

      1) I have a global number field called _g_Page Count Agenda Report.  I have triple checked it.

      2) I have "Page ## of <<_g_Page Count Agenda Report>>" on the layout header and in the footer.

      3) I have a script called "Page Count Agenda Report"

      Go to Layout [Agenda Report]

      Enter Preview Mode []

      Go to Record/Request/Page [Last]

      Set Field [Agenda Report; Get ( Page Number)]

      Go to Record/Request/Page [First]

      Pause/Resume Script [indefinitely]

      Print []

      Enter Browse Mode []

      Set Field [_g_Page Count Agenda Report]

      Go to Layout [original layout]

      4) It doesn't work... The ## is correct but page 2 says "Page 2 of" and never enters Y

      What step did I miss? 

       

        • 1. Re: Page X of Y ... again

          I think your sequence is out of order.

          Enter Preview

          Go to last record

          Set global page count to get page number

          go to first record

          print

          Use // and global page field on your layout.

          • 2. Re: Page X of Y ... again
            philmodjunk

            The syntax in this article is out of date as it doesn't show the tableoccurrenceName::FieldName format that is now required with current versions of FileMaker.

            You might post the exact script you are using.

            To post a script to the forum:

            1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
            2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
            3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
            4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format. (Use the HTML option on the database tab panel and paste the text into the forum's HTML editor.)
            • 3. Re: Page X of Y ... again
              Sorbsbuster

              I think your script should be:

              Go to Layout [Agenda Report]

              Enter Preview Mode []

              Go to Record/Request/Page [Last]

              Set Field [_g_Page Count Agenda Report ; Get ( Page Number)]

              Enter Browse Mode []

              Print []

              Go to Layout [original layout]

              • 4. Re: Page X of Y ... again
                philmodjunk

                Sorbsbuster,

                That does the same as the original script example but returns to browse mode where the example script remains in preview mode ( and thus returns to the first page so the report is in good order to be previewed).

                The original script example should correctly compute the total pages, but I've seen a number of folks have trouble with the set field step the first time that they use it. I've suggested posting the actual script--either copied and pasted as text or as a screen shot, so that we can check for such issues.

                • 5. Re: Page X of Y ... again
                  EricaHeath

                  OK - I changed the order and removed two steps. I think that is what was what Sorbsbuster's instructions were.  It still doesn't work.

                  I am wondering about simple steps akin to asking if the appliance is plugged in.  I think it is in the script but could be something simple.

                  - I am checking it in preview.  That should be a good place to learn if it works or not.  Correct?

                  - The field type is number.  It is stored as global with repetitions = 1.

                  - The layout has it in the header and footer not in the body.  Correct?  seems obvious but ...

                  Do you need a unique page count field per layout?  I created Page Count Agenda Report and a duplicate layout so I don't interfere with other users as I work on this.  Should I simplify things (reduce chances for a mistake) by having only one field?

                  PhilModJunk-Thanks for pointing to the image upload.  I am trying it. Instruction 3 says it will be uploaded when you click save below but there is no Save!  on upload there is "open" and on thr forum there is "post answer".  I hope that post works.

                  The field syntax is likely correct as I used the "specify target field" option and FM entered it.  (FM Advanced 10.0)

                  Thank you first 3.  We are smarter than a program!

                  • 6. Re: Page X of Y ... again
                    Sorbsbuster

                    @Phil:

                    OP's script was:

                    Go to Layout [Agenda Report]
                    Enter Preview Mode []
                    Go to Record/Request/Page [Last]
                    Set Field [Agenda Report; Get ( Page Number)] <--- 'Agenda Report' field set to correct last page number
                    Go to Record/Request/Page [First] <-- now back on the first page
                    Pause/Resume Script [indefinitely]
                    Print []
                    Enter Browse Mode []
                    Set Field [_g_Page Count Agenda Report] <--- no value to set the field to.  Maybe the intention was to collect the Agenda Report field
                    Go to Layout [original layout]

                    • 7. Re: Page X of Y ... again
                      philmodjunk

                      What do you get when you run this script? No value or the wrong value?

                      The script looks correct--provided that _g_Page Count Agenda Report is a field with global storage and this is the field you have placed on your report layout to show the page count.

                      Compare what you have to this demo file:

                      https://www.dropbox.com/s/m2t5g9wttdk4ccw/PageCounterDemo.fp7

                      • 8. Re: Page X of Y ... again
                        philmodjunk

                        @Sorbsbuster,

                        Good catch but I don't think it's the issue here. Set field with no second parameter does not change the value of the target field. Try the above script out and see.

                        • 9. Re: Page X of Y ... again
                          Sorbsbuster

                          I understand that - but there was nowhere that the last page value was being set in the global field that was being merged.  All irrelevant now, of course, with the posted script looking right.  I'm betting on your tip that the merged field is not the correct one for the layout.

                          • 10. Re: Page X of Y ... again
                            philmodjunk

                            Amazing how I can look right at it and be so blind that I can't see it. Embarassed

                            • 11. Re: Page X of Y ... again
                              EricaHeath

                              OK GUYS & GALS

                              It WORKED!!! It was seeing the demo.  THANK YOU PhilMod for the simplicity. 

                              It wasn't exactly the script.  It was something elementary! I added a button to say run script and guess what? - It Ran!!! It's the BUTTON.  I kept thinking that there was nothing there in the script that told the script to start but not understanding it all completely I thought it would be automatic. 

                              This is so exciting...  I can finish up sooo much work now. 

                               

                              Does anyone here have an in to get that answer 3629 modified to add the button?  To fix the script?

                              Seeing this, I now suspect that one generic Page count field will suffice rather than one unique page count field per layout.  True?

                              You are all SOOO Great!

                              Erica

                              • 12. Re: Page X of Y ... again
                                philmodjunk

                                I took a look at the KB article 3629 and it looks correct to me. The original script is set up to temporarily compute the total number of pages. The user is expected to print or save as PDF while the report is paused. It then uses:

                                Set Field [Table::Page Count, ""]

                                To clear the field after it returns to browse mode. It does this so that you either have no page count or the correct page count no matter what the user does. Otherwise, you could run this script, add/delete/change records and preview the report (without the script) and your report would have the incorrect number of pages shown. If I'd gone and looked at the article when you first posted, this would have been a much shorter thread.

                                Thus, the article shows a correct script and is fully updated with current formats. It even shows an option for using a variable instead of a global field.

                                The script, BTW, does not have to be run from a button. It was just a very simple way to set up the demo file. You could also use a script trigger to perform the script. How you perform this script is left up to you in this article and it is assumed you know that creating a script does not cause it to be run automatically unless you set it up to be run that way. Many scripts that produce a report have to do other tasks such as performing a find and sorting the records. In those cases, this page numbering code would be added to that larger script.