Obtain last 2 fields from a list

spnavspnav Member Posts: 7
edited 2008-09-01 in Navision Attain
I am trying to obtain only the last 2 lines from a list. The report lists all the purchase values for items from the value entry table. How can I isolate the output to only the last 2 entries?

Comments

  • DaveTDaveT Member Posts: 1,039
    Hi

    Not sure how your report is structured but I suggest set the sort order descenting and breaking after two lines printed.

    If you are using a record variable then use findlast and next(-1) on the filtered variable.

    Hope this helps
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • spnavspnav Member Posts: 7
    Could you show me an example? thanks
  • DaveTDaveT Member Posts: 1,039
    Hi Spnav,

    if RecordVar.findlast then
      begin
        lastvalue := RecordVar.Code;
        if recordVar.next( -1 ) <> 0 then
           secondlastcode := RecordVar.code;
       end;
    
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • spnavspnav Member Posts: 7
    Thanks for the reply. My problem is that I have a Global variable calculated in the group footer of the section and I cannot obtain the 2 last amounts only.
  • DaveTDaveT Member Posts: 1,039
    Hi Spnav,

    Again there is a number of possibilities one suggestion..

    Declare variables Lastprint, secondprint

    in the group section set

    secondprint := lastprint;
    lastprint := grouptotal;
    currreport.showoutput( FALSE );

    and then add a footer to print the values.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
Sign In or Register to comment.