Results 1 to 5 of 5
  1. #1
    tcheck is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    131

    Int in a summed field

    I have been working on crashing 2 querys together and I fond that the sum of one of the fields are differnent even though if I use the functions of round or INT they shoudl be the same. Then I found the below problem, any help would be appreciated.



    I have a query that has a field that is a Single, Currency in the Access table. When I run a query with the INT function of;

    TotalComm: Sum(Int([compute])) I get 169

    When I run a round function of;
    TotalComm2: Round(1*[compute],2) 170.76

    Here are the totals;
    SumOfcompute3.7200000295.579999924161.4600067

    Why would the INT round it down to 169?

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Not sure why they would be the same. Int() will truncate the decimal portion off each value, round will round it to 2 digits. That decimal portion will cause the Round() function to return a higher value. Your sample data didn't come through right.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tcheck is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    131
    What I am attempting to do is link 2 sums together from 2 different tables that have slightly differnent amounts.

    1st table has three differnt sets
    5.57999992370605
    3.72000002861023
    161.460006713867
    For a total of 170.76
    When I ran the expression of
    TotalComm: Int(Sum([compute_0012])) I received a total of 169 not 170.
    If I ran TotalComm: Int(Sum(Round(1*[compute_0012],2))) I get 170

    The other table just has 170

    I have no idea why.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    I would expect Int(Sum(...)) to return the same value, and it does in my test. Sum(Int(...)) returns 169, again as I would expect, because the truncation would happen before the summing.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    tcheck is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    131

    Thanks

    I got it to work.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 12-15-2010, 01:44 PM
  2. Replies: 1
    Last Post: 11-13-2010, 12:57 PM
  3. Replies: 3
    Last Post: 11-05-2010, 03:10 PM
  4. Replies: 1
    Last Post: 02-26-2009, 11:31 AM
  5. Replies: 0
    Last Post: 02-14-2007, 01:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums