Footer and last item on page

bank_holdupbank_holdup Member Posts: 10
I'm generating a report of our items for a catalog-type print out. Each page has an alphabetical listing of items and all the information comes from the Item card. What I want to do is display a footer for each page that shows the first item on the page and the last item on the page (kind of like in a dictionary). So that when flipping through it, a person can easily see where they are in the catalog. I can get the first item, no problem. But the last item eludes me. Whether I try displaying it directly on a transfooter or a footer, it ALWAYS shows the value for the first listing on the NEXT page. Even if I try using a variable and setting the value to display in the body of the report, I always get the first value from the NEXT page.

Has anyone else run into an issue like this? I did search for similar problems but most of the results I found had to do with summing totals on a page; not what I need to accomplish.

Thanks in advance!
Scott

Comments

  • DenSterDenSter Member Posts: 8,305
    Try something like this... Add a global variable, type Code20, call it 'LastItemNumber'. The last line in your Item's OnAfterGetRecord trigger should say:
    LastItemNumber := Item."No.";
    
    Then put a textbox in the transfooter with SourceExpr LastItemNumber.
  • bank_holdupbank_holdup Member Posts: 10
    Thanks for the suggestion, but no dice. We deal in books, so I'm actually displaying author's names here. But the principle is the same. I assigned the author's name to a variable as the last statement in the OnAfterGetRecord trigger. When I ran the report, I have one page that ends on ALLE-CORLISS, but the bottom shows it going to ALLEN, which is the first author on the next page.
  • SavatageSavatage Member Posts: 7,142
    Is the Number of lines on a page always the same?

    I was thinking doing a count on a second item dataitem that just shows the output every x amount of lines. Just brainstorming, nothing solid.

    I would be surprised if the Transfooter is what you need to use. It's purpose I thought was to show the first line of the next page :shock:
  • BobNYBobNY Member Posts: 3
    I suggest adding code to the OnPreSection footer trigger to create a new table variable, duplicate the range of records used in the report and point to the previous record... something like this...

    1. Create a table (type record) variable for the same data item used in the report, just with a different name.
    2. In the OnPreSection() trigger of the footer, setup this table with an identical query as in the report, point to the current record for the report, then point to the previous record and assign author to a variable to display in the footer. Something like this.
    DataItemTableCopy2.RESET;
    DataItemTableCopy2.SETCURRENTKEY(...same as for original data item);
    DataItemTableCopy2.COPYFILTERS(DataItemTable);
    DataItemTableCopy2 := DataItemTable;
    DataItemTableCopy2.NEXT(-1);
    LastAuthoronPage := DataItemTableCopy2."Author";
    

    If there are other conditions elsewhere in the report which hide records thus adding filters, you may need to repeat conditions or actually run a parallel data item to keep track of the previous record.

    Hope this makes sense.
    Regards,
    Bob
    NY
  • bank_holdupbank_holdup Member Posts: 10
    Savatage wrote:
    Is the Number of lines on a page always the same?

    I was thinking doing a count on a second item dataitem that just shows the output every x amount of lines. Just brainstorming, nothing solid.

    I would be surprised if the Transfooter is what you need to use. It's purpose I thought was to show the first line of the next page :shock:

    The report is not guaranteed to have the same number of lines per page, so a simple counter will not work, unfortunately.

    Maybe I am mistaken but I was under the impression that a Transfooter was a "transitional" footer and the purpose was to show bottom of the current page info, like current page number, subtotals and the like. Out of curiousity, why would you need a special section to see the data you are about to see in the next body?
  • bank_holdupbank_holdup Member Posts: 10
    BobNY wrote:
    I suggest adding code to the OnPreSection footer trigger to create a new table variable, duplicate the range of records used in the report and point to the previous record... something like this...

    1. Create a table (type record) variable for the same data item used in the report, just with a different name.
    2. In the OnPreSection() trigger of the footer, setup this table with an identical query as in the report, point to the current record for the report, then point to the previous record and assign author to a variable to display in the footer. Something like this.
    DataItemTableCopy2.RESET;
    DataItemTableCopy2.SETCURRENTKEY(...same as for original data item);
    DataItemTableCopy2.COPYFILTERS(DataItemTable);
    DataItemTableCopy2 := DataItemTable;
    DataItemTableCopy2.NEXT(-1);
    LastAuthoronPage := DataItemTableCopy2."Author";
    

    If there are other conditions elsewhere in the report which hide records thus adding filters, you may need to repeat conditions or actually run a parallel data item to keep track of the previous record.

    Hope this makes sense.

    I understand the concept and why it should work, but that seems like a lot of overhead to get a single piece of uncalculated data that I just had my hands on. We have almost 1.5 million distinct items and of those between 40,000 and 50,000 will be in the catalog. That seems like a lot of records to put into a temp table, especially given the data I want to access.
  • DenSterDenSter Member Posts: 8,305
    Thanks for the suggestion, but no dice. We deal in books, so I'm actually displaying author's names here. But the principle is the same. I assigned the author's name to a variable as the last statement in the OnAfterGetRecord trigger. When I ran the report, I have one page that ends on ALLE-CORLISS, but the bottom shows it going to ALLEN, which is the first author on the next page.
    It seems that by the time it prints the footer it already processed the next record, including the OnAfterGetRecord trigger code, so you'll have to keep track of the one before the last.

    What about keeping track of the last and the second to last. Add two variables 'LastName' and 'SecondToLastName'. Set SecondToLast to Last, and set Last to the name in the current record. I don't know how else to capture it.
  • DenSterDenSter Member Posts: 8,305
    BobNY wrote:
    I suggest adding code to the OnPreSection footer trigger
    While it might work, it is going to probably cause big performance issues. You should make it a rule to not use any data processing code to section triggers unless you really don't have any other choice.
  • bank_holdupbank_holdup Member Posts: 10
    DenSter wrote:
    It seems that by the time it prints the footer it already processed the next record, including the OnAfterGetRecord trigger code, so you'll have to keep track of the one before the last.

    Is it me or does that seem odd? That when the footer of page 1 is being processed, the header & body of page 2 has already been processed.
Sign In or Register to comment.