Results 1 to 5 of 5
  1. #1
    matt_fdz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    3

    Need help with coordinates query

    I need help running a query to find the nearest coordinates for two separate tables. I have table one with field X and field Y and table two with field X2 and field Y2 and i need to run Sqr(([X]-[X2]^2)+([Y]-[Y2])^2) to find the coordinates from table two which are closest to the coordinates from table one. This will require the formula to be ran against each record of both tables and then display the minimum value for each. Any ideas on how to set up relationships and query to accomplish this?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    This sounds like a homework or test assignment.
    Please tell us more.
    What is your plan of attack? Can you show us some sample data?

    Here's a link that may help you.
    But this one may give you more info.

    Good luck

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I think the formula has a misplaced ) following the first ^2.

    Maybe a Cartesian relation and aggregate query.

    SELECT X, Y, X2, Y2, Min(Sqr(([X]-[X2])^2+([Y]-[Y2])^2)) AS MinDataCalc FROM table1, table2 GROUP BY X, Y, X2, Y2;
    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.

  4. #4
    matt_fdz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    3
    Orange, it's actually just a personal project I'm working on.

    And June7, I did misplace the parenthesis on my post but after looking back at the query I had started it was right. I ran the query you gave me and it worked to calculate the distance for all the values of both tables, but it didn't narrow the results to just the minimum value so now I have a bunch of duplicate coordinates displaying a distance for every value in table 2. Now I've got something to work with, but how can I get it to display just the minimum distance for each duplicate?

  5. #5
    matt_fdz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    3
    Solved it ... Thanks for the help... Just ran a separate query after the one June7 gave meand since all I'm really concerned with is the distance from each coordinate the query below worked just fine

    SELECT SpotsinArra.X, SpotsinArra.Y, Min([MinDataCalc]) AS DistanceFROM SpotsinArra LEFT JOIN PreFinal ON (SpotsinArra.Y = PreFinal.Y) AND (SpotsinArra.X = PreFinal.X)
    GROUP BY SpotsinArra.X, SpotsinArra.Y;

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

Similar Threads

  1. Replies: 1
    Last Post: 05-19-2015, 01:59 AM
  2. Passing form Left and Top positioning coordinates
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 11-18-2013, 08:12 AM
  3. Replies: 1
    Last Post: 11-12-2013, 10:37 AM
  4. GPS coordinates mapping on google map
    By engr_saud1 in forum Forms
    Replies: 1
    Last Post: 05-29-2013, 05:41 AM
  5. Replies: 1
    Last Post: 03-28-2013, 07:21 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