Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office Access
Search
Search
 
Icon: Flag: (c) Microsoft
Get up to speed
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Examples of expressions that look up values in other tables
 

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.