Results 1 to 7 of 7
  1. #1
    PhilJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    4

    Calculation of total incorrect

    Hi all,


    I have a problem with a query, but am posting in the general forum as I suspect the issue may be more to do with issues in datasheet fields.

    In my query, I want to do a basic sum of a cost field per invoice/receipt. I made a query and the outcome is nearly right, but not quite. It seems that the query does not take into account anything past the decimal point when it is performing the sum.

    Going back to the original table, the full number is displayed, but I noticed in design view that the scale property is set to 0. I can change this to 2, to try to get it to save the number after the decimal point, but even after saving the table, opening it again shows that it has reverted to 0. This is not a read-only issue and it happens despite changing the result type to decimal and the format to fixed. Does anyone have any ideas about how I might get the right result from my query? Could it be something to do with the fact that the field in the table uses a Calculated datatype? Any help would be gratefully appreciated!

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,700
    Check everything for an integer data type occurring somewhere.

  3. #3
    PhilJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    4
    Thanks - I just have the one field involved in the calculation and this was set to long integer. I changed it to decimal and specified a scale of 2 with decimal places also as 2, but the same thing happens when I go back to my calculated fields - I can set these as scale 2 but whenever I save and close and reopen, I find it has gone back to 0.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,700
    Where is the sum being displayed? On a form, on a report, being stored in a table? Can you post the query SQL?

  5. #5
    PhilJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    4
    The sum is in a query, just to give me the totals of two fields. The SQL is:
    SELECT subReceiptInvoiceItems.ReceiptID, Sum(subReceiptInvoiceItems.ItemCostPreGSTCalcTotal ) AS SumOfItemCostPreGSTCalcTotal, Sum(subReceiptInvoiceItems.ItemCostIncGSTCalcTotal ) AS SumOfItemCostIncGSTCalcTotal
    FROM subReceiptInvoiceItems
    GROUP BY subReceiptInvoiceItems.ReceiptID;

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,700
    A precision of 2 means that a decimal number can be no greater than 2 digits. (44 or 4.4 or .44)
    A scale of 2 indicates 2 decimal places.
    Try changing your precision to something like 8, or whatever the max number of digits including the decimal in the sums might be.

  7. #7
    PhilJ is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    4
    That did it. Thank you!

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

Similar Threads

  1. Incorrect data
    By Traceyann1964 in forum Database Design
    Replies: 1
    Last Post: 01-20-2016, 09:57 AM
  2. Total Kg FIeld Calculation
    By shazi9b in forum Access
    Replies: 1
    Last Post: 10-28-2013, 03:44 PM
  3. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  4. Total Calculation, nz function, not working
    By Jojojo in forum Programming
    Replies: 3
    Last Post: 10-10-2011, 02:33 PM
  5. Incorrect Sums
    By Azyrus in forum Reports
    Replies: 6
    Last Post: 06-26-2011, 04:27 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