Use the DLookup function to look up a corresponding value in another table when writing Visual Basic for Applications (VBA) code, macros, and expressions. Note that you can't use this function in a data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) or an Access project (.adp).
| Expression |
Description |
| DLookup("[ContactName]", "[Suppliers]", "[SupplierID] = Forms![SupplierID]") |
Displays the value of the ContactName field in the Suppliers table, where the value of the SupplierID field in the table matches the value of the SupplierID control on the active form. |
| DLookup("[ContactName]", "[Suppliers]", "[SupplierID] = Forms![New Suppliers]![SupplierID]") |
Uses the DLookup function to display the value of the ContactName field in the Suppliers table, where the value of the SupplierID field in the table matches the value of the SupplierID control on the New Suppliers form. |