MS Access DLookup function is used to retrieve a single value from a specified set of records. The syntax for the DLookup function is as follows: DLookup(field, domain, criteria). The field argument specifies the field in the domain to return a value from. The domain argument is a string that specifies the table or query to retrieve the record from. The criteria argument is an optional string that specifies the criteria for the record to be retrieved. The criteria can be a simple expression or a more complex expression that includes operators and functions.
The following VBA codes will explain how to use DLookup Function along with a downloadable free sample:
DLOOKUP Function Based on Numeric VBA Code
DLookup("FieldName" , "TableName" , "Criteria = n")
DLOOKUP Function Based on String VBA Code
DLookup("FieldName" , "TableName" , "Criteria= 'string'")
DLOOKUP Function Based on Date VBA Code
DLookup("FieldName" , "TableName" , "Criteria= #date#")
The downloadable sample describes the MS Access DLOOKUP Function along with other functions. In addition, it has the following features and VBA Codes:
- DLookup Function (based on Values & Strings), the main subject.
- Finds and goes to specific record within a sub-form which is another important VBA Code.
- Highlights the current selected record by using the conditional formatting feature.
- Handling of VBA Errors.