Combine Update Query with a Dlookup?

Endlessknight

New Member
Joined
Oct 28, 2016
Messages
36
Greetings All,

I have two tables, Table1 and Table2. Table 1 is a key with two fields, Field1 and Field2, Field1 uniquely determines Field2. Table 2 has the same two fields, and a few others, but often it has an incorrect value in Field2.

What I would like to do is make an update query on Table 2, it takes the value in Table2.Field1 and looks it up in Table1 and returns the value in Table1.Field2 and updates Table2.Field2 to that value.

Not sure if this is possible but I tried to make an update query using table2. In "update to" under field2 I entered DLookUp([Field2],[Table1],[Table2].[Field1]). When I try to run it I get a msgbox asking to enter a parameter value for Table1.

I'm sorry I know that's a convoluted description but any help would be greatly appreciated.

Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Using Dlookup would be an inefficient way of doing this, join the tables in the query:

Code:
UPDATE Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field1 SET Table2.Field2 = [Table1].[Field2]

if you want to use Dlookup then the expression you are updating to would be:

Code:
DLookUp("[Field2]","Table1","Field1 = " & [Field1])
 
Upvote 0
Using Dlookup would be an inefficient way of doing this, join the tables in the query:

Code:
UPDATE Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field1 SET Table2.Field2 = [Table1].[Field2]


That worked perfectly!

Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,327
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top