Lookup values in two table

  • Thread starter Thread starter Anthony
  • Start date Start date
A

Anthony

I am having trouble tying to match values in two different
tables. The basic explanation is Data is enetered into
the main table. I have 2 other tables (Primary and
Secondary) which are used to lookup values for the main
table.
What i want to create is a query that gets all the values
from the main table and returns its lookup value from the
primary table. However, if it is not in there, i want it
to get the vaules from the secondary table.

I have tried using the Dlookup and Vlookup but cant
understand the 'Help' file on how all this works.

If someone can point me in the right direction it woul dbe
much appreaciated.
I have the database in simple format if anyon ewould like
it to give it a try.

Contact me on the above email
 
If your two lookup tables have the same structure, consider merging them
into one with an additional field to indicate the preferred return value(s).

If that is not possible, it would be possible to use a pair of DLookup()
calls inside Nz(). Slow and messy, but okay if you are just looking up one
value at a time. Something like this:
= Nz(DLookup("Field1", "Table1", "xxx"), DLookup("Field2", "Table2", "xxx"))
For help with supplying the "xxx" bit, see:
http://allenbrowne.com/casu-07.html

If you are trying to do this in a query where it happens every row, either
subqueries or a UNION would be more efficient.
 
Back
Top