How total in a body section

DarkHorseDarkHorse Member Posts: 389
Hello, I'd like to know is there is any way to total the amount of a field in a body section. It's possible?.
Thanks in advance.

Comments

  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    YES, O:) the question is bit ambiguous, Anyway....

    1)
    in body - OnPreSection()
           TotalVariable := TotalVariable + AmountField;
    
    This will keep adding the amount field in TotalVariable which can be used.


    2) In the body section we can use record variable....and total a field of that record.
    e.g.
              RecVar.Reset;
              RecVar.Setrange(.........);
              ...........
              .............
              if RecVar.FindSet then
              Repeat
                     TotalVariable := TotalVariable + RecVar.AmountField;
              until RecVar.Next = 0;
    
    

    However, it is a good idea to do data calculations in OnAfterGetRecord() of the DataItem

    I hope it helps.... O:)
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • vanrofivanrofi Member Posts: 272
    Why in a body section? If you use a footer this goes almost automatically...look for example std. report 112.

    Anyway, there are other examples like report 121 where a total is made by a new variable...


    CurrencyTotalBuffer.UpdateTotal(CurrencyCode,RemainingAmt,0,Counter1);

    So meaning : you create a variable where you continuously add a value and you print that :
    dectotal := dectotal + amounttoadd


    Small trick : check out some standard reports, if Nav can do it, you can do it!
  • DarkHorseDarkHorse Member Posts: 389
    Thanks both for reply. I need to do it in a body because after, in that body, I've to do a calculation with the total amount. I'll try that you posted.
    Thanks again.
Sign In or Register to comment.