Dfirst

Return the first value from a specified set of records.

Syntax
      DFirst ( expression, domain, [criteria] )

      =DFirst("[Field]", "Table", "[Field] = 'MyValue'")

Key
   expression The field to return.

   domain     The set of records, a table or a query name.

   criteria   Equivalent to an (optional) WHERE clause.
              Any field that is included in criteria must
              also be a field in domain.

To return the first or last record in a set of records (a domain), create a query sorted as either ascending or descending and set the TopValues property to 1. If the criteria will match a single record, then DFirst and DLast will match the same single row.

The DFirst() function can be used in VBA or in an SQL query.

Examples

In a query:

dfirst

In VBA:

intOrderID = Dfirst("OrderID", "qryOrders", "SupplierID = 64 ")

“If you are planning for a year, sow rice; if you are planning for a decade, plant trees; if you are planning for a lifetime, educate people” ~ Chinese Proverb

Related

First (SQL) - Return the first value from a query.


 
Copyright © 1999-2024 SS64.com
Some rights reserved