Dlookup issue with multiple tables

Pettor

Board Regular
Joined
Aug 8, 2015
Messages
175
Hi All,

I have two tables: TABLE 1 & TABLE 2.

TABLE 1 has past data (until yesterday) and TABLE 2 has today's data.

When the day is done, the data from the TABLE 2 are moved to the TABLE 1 (which is the master table) and the TABLE 2 (which is the temporary one) gets empty.

I have also an import form with which I pick and move only the data I want to a new table (TABLE 3 - that contains only my picks) based on the criteria (code and date) that I enter in the import form.

So, through the form which has 3 fields, exactly like those of the tables (FIELD 1 = a code, FIELD 2 = a date & FIELD 3 = a name) I choose the desired code and date in order to make the registration of all the three fields to the third table.

What I would like to do though is, when I enter the code into the CODE & DATE Fields, the NAME Field of the FORM to appear the name that is related with the other two fields and is already registered in the tables 1 or 2 (it depends on the date that I make the choice).

Normally with a DLookup function on the Control Source I could appear the desired name, but the problem is that the data can be stored either in the TABLE 1 or in the TABLE 2 (based on the date of the registration) and I don't know how to ask access to look in both tables.

Any suggestions on how I could solve that issue? Could it be a possibility to write the DLOOKUP function in a way that it could check where the entry is already stored (Table 1 or 2) and then appear the data?

Thank you in advance!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I would guess you could write a query that unions the two tables, assuming they are the same:

Query1: Select * from Table1 Union All Table2

Then do your lookup on Query1
 
Upvote 0

Forum statistics

Threads
1,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

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