Access: DMin Function
In Access, the DMin function returns the minimum value in a specified set of records (or domain).
The syntax for the DMin function is:
DMin ( expression, domain, [criteria] )
expression is the field that you wish to find the minimum value for.
domain is the set of records. This can be a table or a query name.
criteria is optional. It is the WHERE clause to apply to the domain.
For example:
Let's take a look at a simple example:
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));
VBA Code
The DMin function can be used in VBA code. 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.
SQL/Queries
You can also use the DMin function in a query.
