1 2 Previous Next 15 Replies Latest reply on Jun 2, 2017 11:48 AM by PeterDoern

    Using Page Number to control visibility, etc

    SamRembert

      I have been trying forever to use a change in page number to control whether something on the first body line of a page is visible or not.  Since Filemaker still lacks the ability to prevent page breaks between part breaks,  I often have fields in body lines which are hidden if they are identical to the previous record.  When these break across pages, I want to be able to tell those fields to not hide.  I've tried all sorts of things with Get(PageNumber), but it does not appear that this calculation can be used effectively.  Either that, or I'm just missing something.

       

      I've tried making a calculated field which is just Get(PageNumber), which correctly shows the page number on each line,  then running a script to copy that info into another non-calculated field, but even that doesn't work. 

       

      I'm sure I'm not the first to desire this.  Any ideas?

        • 1. Re: Using Page Number to control visibility, etc
          philmodjunk

          Make sure that any calculation field that uses Get ( pagenumber ) is unstored. Even then, the correct value will not be returned unless layout is in preview mode.

          • 2. Re: Using Page Number to control visibility, etc
            SamRembert

            I do use unstored calculation fields, but it still doesn't seem to work.

             

            Example:

            Field PAGE - Calculation, unstored Get(PageNumber)

            Field PAGETEST - Text

             

            In layout, for field PAGETEST, Hide Object When

                 GetNthRecord (PAGE; Get ( RecordNumber ) - 1)=GetNthRecord (PAGE; Get ( RecordNumber))

             

            This works correctly on the first page only. PAGETEST is hidden for every record except the first one at the top of the page.  Even though the PAGE field correctly shows "2" on the second page for every record (and the correct page number for each page thereafter), the PAGETEST field is hidden on all other records.

             

            Is there something missing here?

            • 3. Re: Using Page Number to control visibility, etc
              philmodjunk

              Your hide object when expression has the context of what record exactly?

               

              What layout part is it located in? Since it's on a layout, the specific record that provides context for that calculation may not be what you think it is.

              • 4. Re: Using Page Number to control visibility, etc
                user19752

                You can't refer another record's page number from unstored calculation, it will be recalculated.

                1 of 1 people found this helpful
                • 5. Re: Using Page Number to control visibility, etc
                  PeterDoern

                  I feel your pain; here's how I solved a similar problem. Caveat: I hate my solution because it's ugly and I would love to find a better way.

                   

                  I built a count sheet report for a client's warehouse. Each SKU can have multiple lots in the warehouse at a given time. So the count sheet is essentially a list of each lot, grouped by SKU. However, there is the possibility of orphaned lots, i.e. lots that appear before or after a page break. I needed to indicate to the client that a SKU had lots on the previous or next pages.

                   

                  Attached is a PDF of 3 pages of the count sheet. If a SKU continues on the next page, I show a down-arrow at the bottom of the page and an up-arrow at the top of the next page.

                   

                  The arrows are a 2-segment button bar. Each segment has a hide condition.

                   

                  Down-arrow hide condition =

                  Let ( [

                   

                       ~num = Get ( RecordNumber ) ;

                       $pagenumber[~num] = Get ( PageNumber )

                   

                  ] ;

                   

                       Case (

                            Get ( WindowMode ) > 1 and

                            Get ( PageNumber ) ≠ $pagenumber[~num + 1] and

                            LOT::SKUrec = GetNthRecord ( LOT::SKUrec ; ~num + 1 ) ;

                                 False;

                            // Else

                                 True

                       )

                   

                  )

                   

                  Up-arrow hide condition =

                  Let ( [

                   

                       ~num = Get ( RecordNumber ) ;

                       $pagenumber[~num] = Get ( PageNumber )

                   

                  ] ;

                   

                       Case (

                            Get ( WindowMode ) > 1 and

                            Get ( PageNumber ) ≠ $pagenumber[~num - 1] and

                            LOT::SKUrec = GetNthRecord ( LOT::SKUrec ; ~num - 1 ) ;

                                 False;

                            // Else

                                 True

                       )

                   

                  )

                   

                  Now for the ugly part. In order to store the $pagenumber[x] variable properly, I have to enter Preview mode and loop forward AND backward through the pages, refreshing on each one. As you can imagine, this is very disarming to anyone used to just clicking Print and being done with it.

                   

                  Here's the print script:

                  Enter Preview Mode [ Pause: Off ]

                  Print Setup [ Restore ; With dialog: Off ]

                  Go to Record/Request/Page [ First ]

                  Loop

                    Refresh Window []

                    Go to Record/Request/Page [ Next ; Exit after last: On ]

                  End Loop

                  Set Variable [ $$PAGECOUNT ; Value: Get ( PageNumber ) ]

                  Loop

                    Refresh Window []

                    Go to Record/Request/Page [ Previous ; Exit after last: On ]

                  End Loop

                  Set Error Capture [ On ]

                  Print [ With dialog: On ]

                  Enter Browse Mode [ Pause: Off ]

                   

                  As I say, I would love to hear about a better way to do this. In the meantime, I hope this helps you with your situation.

                   

                   

                  Peter

                  1 of 1 people found this helpful
                  • 6. Re: Using Page Number to control visibility, etc
                    SamRembert

                    Here is a quick example of a thrown-together database with some random data.

                     

                    Link to FMP database

                    Link to PDF

                     

                    For testing, this is just a list of cities in New York with Zip Codes.  There is a "Page" field, and a "Hide" field.

                     

                    The Page field is an unstored calculation, Get(PageNumber).

                    The hide field is set to be hidden with the following criteria:

                    GetNthRecord (pageheader::Page; Get ( RecordNumber ) - 1)=GetNthRecord (pageheader::Page; Get ( RecordNumber))

                     

                    This works on the first record, as expected.  It does not work on any subsequent page.  Where I would really want to use this is for hiding the city name if it is the same as the previous record, except at the top of each page.  For example, what is the city on the first line of page 3?  I understand that this would only work in Preview/Print, and that is perfectly fine.

                     

                    Thanks for your solution PeterDoern.  I am really hoping there is an easier way to accomplish this.  If Filemaker can calculate the page number, how on earth can it not use the results of that calculation??

                    • 7. Re: Using Page Number to control visibility, etc
                      PeterDoern

                      Since it appears that you always have 25 records per page, make your hide condition:

                       

                      Case (

                           Mod ( Get ( RecordNumber ) ; 25 ) = 1 ;

                                False ;

                           // Else

                                GetNthRecord (pageheader::CityState; Get ( RecordNumber ) - 1)=GetNthRecord (pageheader::CityState; Get ( RecordNumber))

                      )

                      • 8. Re: Using Page Number to control visibility, etc
                        Vaughan

                        SamRembert wrote:

                         

                        For example, what is the city on the first line of page 3?

                         

                        The Header displays the first record on each page.

                        • 9. Re: Using Page Number to control visibility, etc
                          SamRembert

                           

                          PeterDoern wrote:

                           

                          Since it appears that you always have 25 records per page, make your hide condition:

                           

                          In this particular example, yes.  But not in the databases I am actually working on.  There are sub-summaries and other items making each page different.

                          • 10. Re: Using Page Number to control visibility, etc
                            SamRembert

                            Vaughan wrote:

                             

                            SamRembert wrote:

                             

                            For example, what is the city on the first line of page 3?

                             

                            The Header displays the first record on each page.

                            That is helpful, and I do use that for some sub-summary-like parts, but in many cases, I need this as part of the body line.

                            • 11. Re: Using Page Number to control visibility, etc
                              SamRembert

                              Here is an example from the actual database I am working on, showing the missing info on the subsequent pages, and the use of the header for sub-summary-style "continued".  I could add the first body line to that, but then it would appear again below, right?

                               

                              https://dl.dropboxusercontent.com/u/10463776/pagetest2.pdf

                              • 12. Re: Using Page Number to control visibility, etc
                                PeterDoern

                                Ah, the same situation I was in.

                                 

                                After a quick test, how about this as the hide condition on your city:

                                 

                                Let ( [

                                     ~num = Get ( RecordNumber ) ;

                                     ~prev = ~num - 1 ;

                                     $$PAGENUMBER[~num] = Get ( PageNumber ) ;

                                     $$PAGENUMBER.CURRENT = $$PAGENUMBER[~num]

                                 

                                ] ;

                                     Case (

                                          $$PAGENUMBER[~num] ≠ $$PAGENUMBER[~prev] ;

                                               False ;

                                          // Else

                                               GetNthRecord (pageheader::CityState; Get ( RecordNumber ) - 1)=GetNthRecord (pageheader::CityState; Get ( RecordNumber))

                                     )

                                 

                                )

                                • 13. Re: Using Page Number to control visibility, etc
                                  user19752

                                  I use "Hide object when" calculation on object in header (for your layout, "CityState" text can be used) to set a variable,

                                   

                                  Let($$firstRecordID=Get(RecordID);0)

                                   

                                  then use it on target object

                                   

                                  Get(RecordID)<>$$firstRecordID

                                  and

                                  GetNthRecord (pageheader::CityState; Get ( RecordNumber ) - 1)=GetNthRecord (pageheader::CityState; Get ( RecordNumber))

                                  • 14. Re: Using Page Number to control visibility, etc
                                    SamRembert

                                    PeterDoern wrote:

                                     

                                    Ah, the same situation I was in.

                                     

                                    After a quick test, how about this as the hide condition on your city:

                                     

                                    Let ( [

                                    ~num = Get ( RecordNumber ) ;

                                    ~prev = ~num - 1 ;

                                    $$PAGENUMBER[~num] = Get ( PageNumber ) ;

                                    $$PAGENUMBER.CURRENT = $$PAGENUMBER[~num]

                                     

                                    ] ;

                                    Case (

                                    $$PAGENUMBER[~num] ≠ $$PAGENUMBER[~prev] ;

                                    False ;

                                    // Else

                                    GetNthRecord (pageheader::CityState; Get ( RecordNumber ) - 1)=GetNthRecord (pageheader::CityState; Get ( RecordNumber))

                                    )

                                     

                                    )

                                     

                                    Peter!!  At first try, this appears to work just like I want it to!  I will go test it more for sure.

                                    1 2 Previous Next