Results 1 to 6 of 6
  1. #1
    RebeccainGA is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Location
    Atlanta, GA
    Posts
    3

    Question Concatenating multiple fields and comparing with some variance - best approach?

    I'm trying to compare two data tables. In one, latitude and longitude are concatenated already (DD-MM-SS.SS). In the other, they are split into columns (DD, MM, SS.SS in three fields). I need to compare the two coordinates, and need to be able to (if possible) have some variance tolerance - in other words, if the SS.SS isn't exact, but is within 2 seconds, it'll still return a value. If that part needs to be done separately from the original calculation, that's fine - I will gladly split the comparison into steps (exact match, and non-exact match).



    Any help you can provide would be greatly appreciated!

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Can you post a few sample data of the two tables and the resulting data that you are looking for.

    Thanks

  3. #3
    RebeccainGA is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Location
    Atlanta, GA
    Posts
    3

    Examples

    Quote Originally Posted by recyan View Post
    Can you post a few sample data of the two tables and the resulting data that you are looking for.

    Thanks
    The examples are something like this: (field 1, 2, and 3 are from table 1 - Field 4 is from table 2)

    Field 1 Field 2 Field 3 Field 4 Desired Display
    94 42 33.2 94-42-33.4 Match within 1 second
    102 17 42.4 102-17-44 No Match
    087 22 17.1 87-22-17.1 Match within 1 second

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Hi,
    just check out if below gives some guidelines :

    Sub-query to be saved :
    Query1
    Code:
    SELECT 
        Table2.Field4, 
        Left([Field4],InStr(1,[Field4],"-")-1) AS TheFirstPart,
        Mid([Field4],InStr(1,[Field4],"-")+1,(InStrRev([Field4],"-"))-(InStr(1,[Field4],"-")+1)) AS TheSecondPart,
        Mid([Field4],InStrRev([Field4],"-")+1,Len([Field4])-InStrRev([Field4],"-")) AS TheLastPart
    FROM 
        Table2;
    The final query to be saved & run :
    Query2
    Code:
    SELECT 
        Table1.Field1, 
        Query1.TheFirstPart, 
        Table1.Field2, 
        Query1.TheSecondPart, 
        Table1.Field3, 
        Query1.TheLastPart, 
        [Field3]-[TheLastPart] AS TheDifference, 
        IIf([TheDifference]<1,IIf([TheDifference]>-1,"OK","Not Ok"),"Not Ok") AS TheFinalCheck
    FROM 
        Table1 
        LEFT JOIN 
        Query1 
        ON 
        (Table1.Field1 = Query1.TheFirstPart) 
        AND 
        (Table1.Field2 = Query1.TheSecondPart);
    Thanks

  5. #5
    RebeccainGA is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Location
    Atlanta, GA
    Posts
    3
    Quote Originally Posted by recyan View Post
    Hi,
    just check out if below gives some guidelines :

    Thanks
    With that head start, I think I have it working now. Thanks so much!

  6. #6
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Glad you found it helpful.

    Thanks

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

Similar Threads

  1. Replies: 6
    Last Post: 03-13-2013, 03:03 PM
  2. Concatenating fields from matching records
    By MWMike in forum Queries
    Replies: 1
    Last Post: 10-28-2010, 10:49 PM
  3. Comparing fields in Access
    By flames8889 in forum Queries
    Replies: 2
    Last Post: 04-20-2010, 11:55 AM
  4. Concatenating many fields into one field
    By olidav911 in forum Programming
    Replies: 1
    Last Post: 08-13-2009, 05:14 AM
  5. Comparing between fields
    By Dashin in forum Queries
    Replies: 0
    Last Post: 02-13-2009, 08:38 AM

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