Results 1 to 3 of 3
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    UPDATE fields based on another table

    Hi Guys,



    I have table1 with TEXT fields:
    Field1
    Test1
    Test2
    Test3
    Test4

    In Table2 i have dictionary for it, so:
    Field1, Field2
    Test1, Ok
    Test2, No
    Test3, Yes
    Test4, No problem

    So i want to write SQL query to update fields in Table1 using Table2:

    UPDATE Customers
    SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
    WHERE CustomerID = 1;
    So in my example:

    UPDATE Table1
    SET Field1= "Ok"
    WHERE Field1 = "Test1"

    UPDATE Table1
    SET Field1 = "No"
    WHERE Field1 = "Test2"

    and so on and so on.

    So insted of writing 10 times this SQL query i would like to create automation for it.
    Maybe using Dlookup function or VBA?

    Can you please help me?

    Warm regards,
    Jacek Antek

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in the query , add both tables to the query,
    join the field1 on both,
    now update using

    set table1.field1 = table2.field2

  3. #3
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Thank you Ranman256 !!!

    Best Wishes,
    Jacek

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

Similar Threads

  1. Replies: 12
    Last Post: 11-14-2017, 12:46 AM
  2. Replies: 6
    Last Post: 02-17-2017, 08:57 AM
  3. Replies: 6
    Last Post: 08-22-2013, 08:47 PM
  4. Replies: 1
    Last Post: 10-29-2012, 08:15 AM
  5. Update 2 fields based on where condition.
    By Confused in forum Access
    Replies: 2
    Last Post: 11-19-2009, 05: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