This MSAccess tutorial explains how to use the Access DLookup function with syntax and examples.
Description
The Microsoft Access DLookup function returns a value from an Access table (or domain).
Syntax
Placing the VLOOKUP formula. Most people just put formulas into random cells. Vlookup and concatenate multiple matching values in a cell with Kutools for Excel. If you have Kutools for Excel, with its Advanced Combine Rows feature, you can quickly finish this job with ease. This feature can help you to combine all matching values with a specific delimiters based on the same data in another column. Vlookup function of excel can be used in the VBA as well with the same syntax that we used in Excel. Open a module in VBA and define a variable for Lookup value and then declare the cell where we will be applying Vlookup using VBA. In Excel, use VLOOKUP when you need to find things in a table or range by row. Learn more at the Excel Help Center: highly antic.
The syntax for the DLookup function varies depending on what datatype you are uisng in the last parameter. Below we show how to use the DLookup function with numeric, string, and date value in the final parameter.
Numeric
String
TIP: Notice the single apostrophe before and after the string value.
Date
TIP: Notice the # symbol before and after the date value. Mac high sierra direct download.
Parameters or Arguments
- FieldName
- A field, calculation, control on a form, or function that you wish to return.
- TableName
- The set of records. This can be a table or a query name.
- Criteria
- Optional. It is the WHERE clause to apply to the TableName.
Returns
The DLookup function returns any datatype such as a string, numeric, date, etc.
Applies To
The DLookup function can be used in the following versions of Microsoft Access:
- Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
Example
Let's look at how to use the DLookup function in MS Access:
Vlookup Excel Function Example
In this example, you would be retrieving the UnitPrice field from the Order Details table where the OrderID is 10248. This is the same as the following SQL statement:
You can also retrieve a calculation using the DLookup function. For example:
Mac os high sierra dmg download. This example would return the UnitPrice field multiplied by the Quantity field from the Order Details table where the OrderID is 10248. This is the same as the following SQL statement:
Lookup Excel Formulas And Functions
You could also use a form control in the DLookup function. For example:
This example would return the CustomerID field from the Orders table for the record that is currently being displayed in the Orders form (based on OrderID).
Example in VBA Code
The DLookup function can be used in VBA code in Microsoft Access.
For example:
In this example, the variable called LDate would now contain the OrderDate value from the Orders table where the OrderID is 10248.
Example in SQL/Queries
You can also use the DLookup function in a query in Microsoft Access.
For example:
In this query, we have used the DLookup function as follows:
This query will return the OrderDate from the Order Details table where the OrderID is equal to 10248. The results will be displayed in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
Dlookup Examples
For example:
Ms Excel Dlookup
The results would now be displayed in a column called OrderDateValue.