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

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
 
A

Allen Browne

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
 
S

Steve

I was able to figure it out using subqueries with the info from your website.
Thanks.
 

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