Last returns the field value from 'Last' record in a recordset formed
from an aggregate query: We used to use it for returning the last of a
historical series up to a given date:
select Last(idxAudit) as idx, idxRecord from tbl
where dt < #1/1/2000#
group by idxRecord
However, it was unreliable, and in recognition of this, for years MS
has only said 'returns a random value'
A Jet table with an ascending autonumber primary key will always
be sorted in primary key order, and so should have a first and
a last. A query with a specified sort order should also have a
first and a last (for the whole recordset, and for any defined subset).
Unfortunately, in evaluating complex queries, First and Last did not
always applied to the correctly sorted set. Sometimes, First or
Last really did return a random value. Even though you could see
that the recordset was correctly sorted when Selected, when you
applied the grouping, First and Last returned the wrong values.
We became aware of this when we started using A97, and the help
files(not worthless then as it is now) warned us off, but in fact, once
we started looking, we saw the problem in A2 (Jet 2.5). So in fact
I don't remember if we ever actually saw the problem with Jet 3.5,
and I know we never saw the problem with Jet 4.0, because we
never use First and Last that way anymore.
So AFAIK, Jet 4.0 is the same as Jet 2.5: First and Last appear to
select values from the First and Last records, using the sort order
you have specified or the 'default sort order' of the table, but rarely
the query plan is out of order, and you get a random record instead.
We still use First where we know all the values in a group are identical,
or irrelevant, on the basis that it must be faster and easier than using
MAX.
(david)