DLookup() is perfectly appropriate for looking up a single value from a
table. Use it. The only programmatic flaw with DLookup() is that it fails to
distinguish between a Null and a zero-length string.
If you want to do it on every row of a *query*, it would be much better to:
a) Add the lookup table to the query, or
b) Use a subquery.
For a), use an outer join. Details in:
The Query Lost My Records!
at:
http://allenbrowne.com/casu-02.html
In subqueries are new, see:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066
If the subquery outputs a value, the results will be read-only.
In *code*, where you need to lookup values repeatedly (in a loop), the most
efficient approach would be to OpenRecordset using a SQL statement that
selects ony the records you want, sorted as you want. You can then walk the
recordset as needed. Because it remains open, this is hugely more effient
that opening and closing recordsets or making multiple DLookup() calls.
This link contains a replacement for DLookup():
http://allenbrowne.com/ser-42.html
While it is more efficient than DLookup(), it is still much slower than the
alternatives given above. The main advantage of the ELookup() function is
that it lets you specify how to sort the records to retrieve, whereas
DLookup() is pot-luck (i.e. you just get whichever value is first in the
set, without being able to specifiy how the records are sorted.)