help, howto determine last record?

andihpandihp Member Posts: 7
Hi All,
How to determine if the current record is the last record from a table in report?
TIA
Andi

Comments

  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    The record in the footer section is always the last. So put code that needs to work with the last record in the onpresection of the footer.
  • kinekine Member Posts: 12,562
      Rec2.COPY(Rec1);
      if Rec2.Next=0 then
        //Rec1 is last one...
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,307
    You should never put any type of processing code in any of the section triggers.

    I would use FINDLAST on a separate variable, and I would put the code in one of the 'Pre' triggers. Then as you are processing the records I would put something in OnAfterGetRecord to compare the current record with the last record that you retrieved earlier.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    andihp wrote:
    Hi All,
    How to determine if the current record is the last record from a table in report?
    TIA
    Andi

    Hmm a lot of differnt opinions here. Personally I would put the code in the:

    MyRec-OnPostDataItem section.
    David Singleton
  • Alex_ChowAlex_Chow Member Posts: 5,063
    andihp wrote:
    Hi All,
    How to determine if the current record is the last record from a table in report?
    TIA
    Andi

    Hmm a lot of differnt opinions here. Personally I would put the code in the:

    MyRec-OnPostDataItem section.

    But this will only give you the last record based on what you filtered and what keys you set.

    Perhaps this is what the user will need. Are you trying to find the last record based on the keys and filters set on the report? Or the last record on the table without keys or filters?
  • diptish.naskardiptish.naskar Member Posts: 360
    Agreed with David,

    Post data item is the answer of this.[/quote][/code]
    Diptish Naskar
    For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Agreed with David,

    Post data item is the answer of this.
    Thanks :wink:
    deadlizard wrote:
    But this will only give you the last record based on what you filtered and what keys you set.

    Perhaps this is what the user will need. Are you trying to find the last record based on the keys and filters set on the report? Or the last record on the table without keys or filters?

    I think in most cases when someone runs a report and say last record, that means generally the last record that is accessed in that section.

    Also it depends what they want to know the last record for. If its to do some processing and modify records, as Daniel suggests, then I prefer to put the code in OnPostDataItem. If on the other hand the person really just wants to print a line differently than the previous lines, then they are probably going completely the wrong way about it, and instead of knowing its the last record, they should just print either a footer, or something else most Navision standard and forget about coding it. Its common to see C++ and VB programmers that try to replicate Navision report functionality in Code because they are more comfortable that way.

    I often see reports with code to group totals instead of using Navision's grouping feature.
    David Singleton
  • Alex_ChowAlex_Chow Member Posts: 5,063
    For reporting purposes sometimes I want to get the last receipt date or the last entry no for purchase receipts. This way, I can see if something was backdated after I ran my financial reports.

    I did create a report that did something similiar like this. So it really depends on what the user is looking for.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    deadlizard wrote:
    ... So it really depends on what the user is looking for.

    Yes exactly, and it does seem that andihp has left the building.
    David Singleton
  • Alex_ChowAlex_Chow Member Posts: 5,063
    deadlizard wrote:
    ... So it really depends on what the user is looking for.

    Yes exactly, and it does seem that andihp has left the building.

    LOL :lol::lol::lol:

    Love the ask and run users. Let all the people beat the topic like a dead horse when he probably figured out the answer already on his own.
Sign In or Register to comment.