Totalling an Integer Field

madmmadm Member Posts: 92
edited 2005-03-01 in Navision Attain
I am trying to add a total to a field which is classed as an integer.

the contents are 1
2
3
etc

i would like to calculate them to give total 6. From my understanding, as this is not a decimal field then i cannot calculate on it?

Is this correct, and if not, how would i go about adding a total field to the footer?

Thanks

Comments

  • kinekine Member Posts: 12,562
    The values are in some global variable or in some table you are using in the report?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • madmmadm Member Posts: 92
    the field is actually in the table.
  • kinekine Member Posts: 12,562
    I don't know why you have problem with totaling integer. It is same as totaling decimal... if the table is used as dataitem in the report, use the dataitem property TotalFields. If it is your variable, use CurrReport.CREATETOTALS(rec.field) to automatically create the totals...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • madmmadm Member Posts: 92
    thanks for you prompt replies.

    i think i was having a "bad" moment when i started the report.

    I tried the totalfields method and got :

    The fields specied in the TOTALFIELDS property must be of type decimal. The *field* in *table* is not a decimal.

    I then went on to declare a variable and use totalamount := totalamount + *field*

    however :oops: i used the pre, rather than the onafter record trigger which gave me zeros!


    i have now corrected this, but the totals which im received are running totals. I have the report grouped, but the total for each group, is the total so far. (I am using a groupfooter)
  • kinekine Member Posts: 12,562
    if you are using CreateTotals, the totals are calculated automatically - the report take the value of the variable on the end of OnAfterGetRecord and make the totals and subtotals as needed... you must not to use
    totalamount := totalamount + *field*
    

    you need only:
    OnPreDataItem
    
       Currreport.CREATETOTALS(TotalAmountVar); //or replace TotalAmountVar with *field*
    
    OnAfterGetRecord
    
      TotalAmountVar := *value* ;   //or *field*
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • madmmadm Member Posts: 92
    thanks alot - working now!

    Youve been a great help :)

    (although im on to my next problem now :D)
Sign In or Register to comment.