MS Access: DMin Function
This MSAccess tutorial explains how to use the Access DMin function with syntax and examples.
Description
The Microsoft Access DMin function returns the minimum value from an Access table (or domain).
Syntax
The syntax for the DMin function in MS Access is:
DMin ( expression, domain, [criteria] )
Parameters or Arguments
- expression
- The field that you wish to find the minimum value for.
- domain
- The set of records. This can be a table or a query name.
- criteria
- Optional. It is the WHERE clause to apply to the domain.
Returns
The DMin function returns a numeric value.
Applies To
The DMin function can be used in the following versions of Microsoft Access:
- Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
Example
Let's look at how to use the DMin function in MS Access:
DMin("UnitPrice", "Order Details", "OrderID = 10248")
In this example, you would return the minimum UnitPrice from the Order Details table where the OrderID is 10248. This is the same as the following SQL statement:
SELECT Min([Order Details].UnitPrice) AS MinOfUnitPrice FROM [Order Details] WHERE ((([Order Details].OrderID)=10248));
Example in VBA Code
The DMin function can be used in VBA code in Microsoft Access.
For example:
Dim LMin As Currency LMin = DMin("UnitPrice", "Order Details", "OrderID = 10248")
In this example, the variable called LMin would now contain the minimum UnitPrice from the Order Details table where the OrderID is 10248.
Example in SQL/Queries
You can also use the DMin function in a query in Microsoft Access.
For example:
In this query, we have used the DMin function as follows:
Expr1: DMin("UnitPrice","Order Details","OrderID = 10248")
This query will return the minimum UnitPrice value 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.
For example:
MinValue: DMin("UnitPrice","Order Details","OrderID = 10248")
The results would now be displayed in a column called MinValue. This example is just used for demonstration purposes to show how to use the DMin function and what it would return.
Advertisements