Query for Single Field Value Where Another Field is at it's Max

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have a table called tblCompletedMessages which gets updated information
constantly from my department. A new row with the latest information is added
every few minutes. I would like to be able to query the value of a field
called "PctOfStd" where the time field "TimeCompleted" is at it's maximum for
a given date (the date is selected from a calendar control on a form) so that
I will have the most recent PctOfStd for the date. I thought this would be
pretty easy, but I can't get it to work. Any input would be appreciated.

Steve
 
Not sure what context you are wanting this.

DLookup() can get a record, but not the last one. There's an extended
replacement name ELookup() here:
http://allenbrowne.com/ser-42.html
Use it like this:
=ELookup("PctOfStd", "tblCompletedMessages", , "TimeCompleted DESC")

If you are seeking to do this for multiple related records in the context of
a query, a subquery would be more efficient. For an introduction to
subqueries:
http://allenbrowne.com/subquery-01.html
 
Back
Top