Others

Fix Microsoft Access Last Function Not Returning the Latest Date

Tauseeq MagsiTauseeq Magsi Nov 14, 2026 869 views

Question details

The user needs to retrieve the most recent visit date or record for each client in Microsoft Access.

Fix Microsoft Access Last Function Not Returning the Latest Date
Product
Microsoft Access
Device & OS
not provided
Scenario
A grouped query uses First and Last to find client visit dates and times.
Observed behavior
Last does not reliably return the latest date or time in each client group.
Before you start

Check that the visit date and time fields use the Date/Time data type and identify the client ID field that links the tables. Decide whether you need only the maximum values or the complete row associated with the latest visit.

Solution 1Recommended

Use Max to Return the Latest Date for Each Client

Use this approach when you need the latest date or time values for each client, rather than an entire visit record.

1
Open the query in SQL View

In Microsoft Access, open the query in Design View, then choose View > SQL View.

2
Replace Last with Max

Enter a grouped query such as: SELECT Clients.ClientID, Clients.FirstName, Clients.LastName, Max(VisitsLog.DateTimeIn) AS LatestIn, Max(VisitsLog.DateTimeOut) AS LatestOut FROM Clients INNER JOIN VisitsLog ON Clients.ClientID = VisitsLog.ClientID GROUP BY Clients.ClientID, Clients.FirstName, Clients.LastName; Adjust the table and field names to match your database.

3
Run the query

Select Run on the query toolbar and check the latest values returned for each client.

Use Max to Return the Latest Date for Each Client
Maximum values may come from different visits: LatestIn and LatestOut are calculated independently, so they do not necessarily belong to the same row. Use the correlated subquery method when you need the fields from a single latest visit record.
Free Microsoft Office alternative

Review Exported Access Data in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface for working with exported data. Export Access query results to an Excel workbook to review them in WPS Spreadsheets; WPS does not fix or run Access database queries.

Review exported client visit dates in a spreadsheetOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for an easier transitionWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't Last return the most recent date in Access?

Last returns a value based on the records encountered by the query, not necessarily the greatest date. Use Max on the Date/Time field to find the latest value in each group.

How do I find the latest date for each client?

In a grouped query, include ClientID in the GROUP BY clause and use Max on the visit date field. Run the query from SQL View to see the latest value for each client.

How can I get other fields from the latest visit row?

Use a correlated subquery that compares each visit's date with Max of the date for the same ClientID. Selecting T1.* returns the fields from matching visit rows.

What happens if two visits have the same latest timestamp?

The correlated subquery returns both rows because each matches the maximum timestamp. Add a suitable tie-breaking rule if you need exactly one row.

Do Max(DateTimeIn) and Max(DateTimeOut) always describe the same visit?

No. Each Max is calculated independently, so the values may come from different rows. To keep visit fields together, select the latest row using a correlated subquery.