Results 1 to 6 of 6
  1. #1
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60

    Currency calculations within a query

    In a query I have 'tonnes' & 'sale price' from a table.



    Within the query I have created expressions to calculate the costs of VAT & totals etc. The properties are set to currency & 2 decimal places.

    When it performs the calculations it uses 3 decimal places though only shows 2.

    For example the sale price with vat = £2.35 & the customer had 98 bags - £2.35 * 98 = £230.30, though access shows £230.50 which means it is calculating using £2.352.

    Any ideas would be really appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I use VBA. Each side of the calc gets its own variable rounded to two decimal places, using only the format() function. If you just format the result, the underlying values will not change during the calc. Format before the calc. You should be able to do the same in the SQL statement.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    when you do your final calculation you can do something like

    ((int(vat*100))/100) * 98

    instead of

    vat * 98

  4. #4
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60
    Thanks

    This works by rounding down which is fine on the ones like 3.592, but if it's 3.598 I need it to round up.

    All sorted, using 'cint'

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I took at look at some of my DB's and where I thought I was using format I was using the Round() function. I tried it in a query and SQL recognized it. 5 rounds down and 6 rounds up.

    ((Round([TableName].[Value],2))*[TableName].[Quantity]) AS MyResult


    Edit: Having said that. I store currency with two decimals typically. If your quarterlies count pennies you will be off by a few pennies unless you always apply the Round() function. Not sure exactly how or why you have three decimal places in a table but maybe you can apply the round function before storing the result.
    Last edited by ItsMe; 04-25-2014 at 09:56 AM. Reason: Added Comment

  6. #6
    Pure Salt is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    60
    Thank you for your help

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

Similar Threads

  1. Currency query
    By sdc1234 in forum Queries
    Replies: 2
    Last Post: 04-18-2014, 07:31 AM
  2. Query to stop rounding off currency
    By Ruegen in forum Queries
    Replies: 4
    Last Post: 07-24-2013, 09:49 AM
  3. Replies: 2
    Last Post: 01-13-2012, 02:33 PM
  4. Replies: 32
    Last Post: 01-02-2012, 12:30 AM
  5. Replies: 2
    Last Post: 03-23-2011, 11:43 AM

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