Results 1 to 4 of 4
  1. #1
    halabis is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Aug 2014
    Posts
    44

    Querying the most recent record

    I am attempting to design a query that will pull the most recent entry into to database for each employee that meets a specific criteria. I then need to Every tutorial I can find on how to do this is for Access 2007 and has you enter values into the "Total" line on design view. As far as I can tell there is no such equivalent of this in Access 2013.



    So if I have the Following

    Employee / Date / Filter
    Bob / 10-1/15 / Yes
    Bob / 10-5-15 / No
    Bob / 9-1-15 / Yes
    Sam / 6-1-15 / Yes
    Sam / 6-2-15 / Yes


    I would like the query to return

    Bob / 10-1-15 / Yes
    Sam / 6-2-15 / Yes


    As those are the most recent dates for each employee for which the filter field is a "Yes"

    Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,649
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    This is done in 2 steps. First make a query 'TheYesGroup' ...that is a select query with the criteria of Yes.

    then make an Aggregate query using TheYesGroup as its record source - and set the date field to Max...let the other fields remain at the default Group.

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845
    It can be done in one query

    SELECT *
    FROM myTable
    WHERE myDate= (SELECT Max(myDate) FROM myTable AS T WHERE Employee=myTable.Employee AND myFilter = True)

    note that date and filter are reserved words so should be changed in your solution

    filter may be text rather than Boolean so change to suit

    also see the answer here

    https://www.accessforums.net/queries...tml#post300708

    almost the same question

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query for most recent record
    By Icon in forum Queries
    Replies: 10
    Last Post: 01-15-2014, 06:27 AM
  2. Replies: 1
    Last Post: 07-23-2013, 01:39 AM
  3. Querying for the last record of a table
    By Reaper in forum Queries
    Replies: 7
    Last Post: 11-04-2011, 04:27 PM
  4. Get Recent Record without Id or date
    By pyog in forum Queries
    Replies: 5
    Last Post: 04-19-2011, 09:43 AM
  5. Displaying Most Recent Record
    By viper in forum Forms
    Replies: 7
    Last Post: 11-16-2010, 10:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums