Dlast vs Dmax

E

Ed

Hi all: can anyone please help with a simple def and the difference between
dlast & dmax? It seems that i get the same result from both but sometimes
dlast does not give correct result. I use it to open a form to the last or
maximum [formId] in criteria.
Thanks, Ed
 
K

Ken Snell

DLast is a function that returns the value of a field from the "last"
record..... and how is "last" defined, you may well ask? Well, it's defined
based on the ORDER BY clause of your query. If you're not using a query,
then there is no consistency nor guarantee about which record will be the
last, because ACCESS does not store records in a table in any particular
order, regardless of the order in which you may have added the records.

DMax is a function that returns the maximum value of a field from the table
or query. It is independent of any order imposed by a query or indices. It
is always going to return the maximum value.

Programmers rarely use DLast, preferring to use DMax (and its cousin, DMin)
instead.
 
R

Rick Brandt

Ed said:
Hi all: can anyone please help with a simple def and the difference between
dlast & dmax? It seems that i get the same result from both but sometimes
dlast does not give correct result. I use it to open a form to the last or
maximum [formId] in criteria.

The details are sketchy, but First(), Last(), DFirst(), and DLast() are (for the
most part) useless. First() And DFirst() are sometimes used when you absolutely
don't care which record in a set you get. Using the Min and Max alternatives is
recommended.

(there's likely a reason that most DBMS systems don't even have these functions)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top