Mark C.
Mark C.

Reputation: 6460

Get Most Recent Record

The question speaks for itself, for the most part. I have 2 fields in a table, Date and Value. By the most recent date, I would like to use the dollar value. I would like to get these values by means of VBA code.

Is this possible with a DLookup or DMax, or something similar?

What I have now searches dates quarterly, however quarterly is not the correct solution I've come to figure out, as the quarterly updates are sent out too late to use.

Upvotes: 1

Views: 446

Answers (1)

HansUp
HansUp

Reputation: 97131

You can use TOP 1 in a query sorted by Date in descending order.

SELECT TOP 1 y.Date, y.Value
FROM YourTable AS y
ORDER BY y.Date DESC;

Upvotes: 1

Related Questions