mohchu
mohchu

Reputation: 29

Issue with Dlookup

I have two table, say table 1 and table 2. Columns in two table have below heading.

Table 1
1. ABC
2. DEF
3. GHI

Table 2
1. ABC
2. FED
3. IHG

As in excel, we use Vlookup between column 1 in table 1 and table 2 and than pick value from column 2 of table 2, I need to update value in column 1 in Table 1 using column 2 in Table 2. and column 1 is common in both table. e.g Vlookup(Column1. table 1, [1 and 2].table 2, 2 , )

In access, i m using update query and updating Column 1 of Table 1 using below formula.

Column 1.table 1 = Dlookup("[Column 2].[Table 2]", "Table 2" , "[Column 1].Table2  = '[Column 1].table1 '")

I am using Dlookup for type text. So I have applied formula for string one.

I am not getting desired value that I should get in normal Vlookup. Instead, I am getting blank as final result. Why is this happening?

Upvotes: 2

Views: 108

Answers (1)

SunKnight0
SunKnight0

Reputation: 3351

First of all, database notation is Table.Column and not Column.Table. If your tables and or columns have spaces or other special characters you always need brackets (and you have already made a bad start in your database design, never use spaces or other special characters for names).

Assuming your actual logic is correct what you need is:

[Table 1].[Column 1] = DLookup("[Column 2]","[Table 2]","[Column 1]='" & [Table 1].[Column 1] & "'")

But I don't think your logic itself is correct unless you are really trying to replace the value you are looking up by.

Upvotes: 2

Related Questions