Results 1 to 4 of 4
  1. #1
    fblanchard is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    2

    Use query or table to update another table

    I have a table (the MAIN table) with station IDs and coordinates, as well as other information. The coordinate columns in this table (Latitude and Longitude) have some records with unknown coordinates. I queried out the Stations IDs with only unknown coordinates and grouped by. I would like to use this query to update the main table by typing in the new coordinates in the query and allowing it to populate the main table coordinates that match the same station IDs in the query.



    I also converted the query into a table if it is easier to connect two tables with the same cirteria as above.

    I hope this makes sense and would appreciate any advise.

    Thank you.

  2. #2
    Bob McClellan is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Location
    New Jersey
    Posts
    17
    Quote Originally Posted by fblanchard View Post
    I would like to use this query to update the main table by typing in the new coordinates in the query and allowing it to populate the main table coordinates that match the same station IDs in the query.

    I also converted the query into a table if it is easier to connect two tables with the same cirteria as above.
    If table2 is the target being updated and table1 has the values that you want
    to update from... then something like this should work....
    PLEASE BACKUP YOUR TABLES PRIOR TO TRYING YOUR UPDATE QUERY.

    Update Table2
    set Longitude = table1.Longitude,
    Latitude = table1.Latitude
    from Table2
    inner join Table1 on Table2.[Station ID] = Table1.[Station ID]

    hth,
    ..bob

  3. #3
    fblanchard is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    2
    Table 1 does not have the values in yet. I want to be able to enter it into table 1 as I get them and have it update table 2. Table 1 has all unique Station IDs (12) and table 2 has those same Station IDs duplicated (300,000+).

  4. #4
    Bob McClellan is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Location
    New Jersey
    Posts
    17
    So... let's say you want to update the 300k rows in table 2 for [Station ID] = 1
    After populating the long / lat in table 1 for [Station ID] 1, then run the query
    with the additional parameter... where Table1.[Station ID] = 1

    There are a number of ways to do this....
    You could also have the params in the qbe grid in brackets. this will prompt you for the params when you run the query....

    OR Disregard table 1 altogether and simply use a query that says...
    Update Table2 set Longitude = [What is the longitude] where [Statioin ID] = [What Station ID should be updated?]

    When you execute the query, it will prompt you with What is the longitude then it will prompt you with What Station ID should be updated? prior to executing the query.

    hth,
    ..bob

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

Similar Threads

  1. Replies: 2
    Last Post: 12-22-2010, 01:46 PM
  2. Replies: 0
    Last Post: 11-30-2010, 12:23 PM
  3. Why doesn't the table & Query update?
    By U810190 in forum Forms
    Replies: 1
    Last Post: 03-29-2010, 04:07 AM
  4. Replies: 3
    Last Post: 01-21-2010, 08:10 PM
  5. Replies: 4
    Last Post: 09-03-2009, 02:01 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