Results 1 to 8 of 8
  1. #1
    BCJourney is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Location
    Cincinnati, OH
    Posts
    46

    Question compare two values rounding problem

    I have an unmatched query that returns records where query1.value1 <> query2.value1


    The problem is that the numbers in their source tables are both formated as field size: Double, Format: 0% but the query will return the records as unmatched anyway. I'm sure this has to do with when the tables were imported, one value ran 10 decimal places and the other table only 2. I thought that since they have been formatted the same after import that it would be recognized as the same number. Any suggestions?

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    The formatting features you listed only affect how the data is displayed, not the actual value held in the field. You can store up to 10 decimal places, but only display 2.
    If you want to compare them in an unmatched query, first create a query using the round function in a calculated field to round the 10 decimal place values to 2. Then use that query in a new query with your other table and it should work.

  3. #3
    BCJourney is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Location
    Cincinnati, OH
    Posts
    46
    Thank you for your help. I did that and that may work fine, but one table rounds up while the other one rounds down, thus creating a mismatch. Can you help?

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Then create creates for both of them, rounding them both the way you like, and then perform an unmatched query between those two queries to get what you need.

  5. #5
    BCJourney is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Location
    Cincinnati, OH
    Posts
    46
    I did queries for both. when i round one to percent with 0 places, it shows that way but when you click on it after the query is run it shows a million decimal places. any other suggestions?

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Where are you rounding them? Rounding them in the Properties or Format is no good. That only changes what is displayed, not what is actually stored or used in calculations.
    You need to round them in calculated fields in your query before comparing them, i.e.
    MyRoundedField: Round([FieldName],2)

    Create new queries rounding the field in each table, then use these two queries in your unmatched query, matching on the new "rounded" fields.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Also, be aware that Round() function in Access uses an even/odd rule (aka banker's rounding):

    Round(3.144,2) = 3.14
    Round(3.145,2) = 3.14
    Round(3.146,2) = 3.15
    Roune(3.175,2) = 3.18
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    BCJourney is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2012
    Location
    Cincinnati, OH
    Posts
    46
    I think I got it now. Thank you for you patience.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-06-2013, 12:18 PM
  2. Rounding Problem With Percentages
    By Lady_Jane in forum Queries
    Replies: 5
    Last Post: 09-01-2011, 02:32 PM
  3. Rounding problem
    By chavez_sea in forum Access
    Replies: 6
    Last Post: 03-09-2011, 09:01 PM
  4. Rounding problem
    By jgelpi16 in forum Queries
    Replies: 1
    Last Post: 04-06-2010, 10:27 AM
  5. Replies: 3
    Last Post: 04-04-2010, 05:26 PM

Tags for this Thread

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