Results 1 to 6 of 6
  1. #1
    guillermoftw is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    13

    Arrow Updating a column with the value of another Column


    This is a bit difficult to explain, but I'll do my best. I imported a excel sheet to create a new table in my DB. In the table I would like to update the column is called one thing but in my imported excel doc its named another but cannot be changed. Can a JOIN identify what values it needs to change based off two different column names?

    Table A Table B
    --------- -----------
    Name Name 2
    "This needs updated" "This column will update A"

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I don't see how a JOIN is needed. Both fields are in the same table then run an UPDATE query that populates one field with values from the other.

    UPDATE tablename SET FieldA = FieldB;

    Do you do this import on a regular basis?
    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.

  3. #3
    guillermoftw is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    13
    I do import on a regular basis. Its saved in the Macro I am creating. I wasn't specific enough I'm sorry. A specific ID along with another field need to match up with both tables before the values in Table B can overwrite Table A. If I do it without the JOIN it will just overwrite all fields when I only need it to specific fields.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I am confused, if the Excel data is imported, what two tables need to be joined? Describe the entire process.
    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.

  5. #5
    guillermoftw is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    13
    I originally updated two tables from this excel spreadsheet manually until I realized I could import the excel sheet into its own table and update it from there. My first step is identify which table should be updated from the excel sheet by a value in one column. Once the correct table is chosen by the macro the SQL statement will choose an ID and another value to match the values in the excel sheet to match up. Once those values are matched, the SQL statement will run an UPDATE.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I don't use macros, only VBA.

    Can't do this with a single query object because the tables in FROM clause cannot be dynamic.

    I would run an SQL action constructed in VBA procedure.
    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.

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

Similar Threads

  1. Replies: 8
    Last Post: 07-29-2014, 12:35 PM
  2. Replies: 3
    Last Post: 08-08-2011, 11:02 AM
  3. Replies: 7
    Last Post: 06-10-2011, 05:40 AM
  4. Updating table's column via VBA
    By Amerigo in forum Programming
    Replies: 10
    Last Post: 03-24-2011, 10:07 AM
  5. Replies: 1
    Last Post: 04-15-2010, 02:07 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