Results 1 to 3 of 3
  1. #1
    andresdm is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    6

    Searching For Last Item

    Hello,

    I have a table where I am tracking comments for a record in another table. The comments table has it's key, a claim ID, a comment date, a follow up person, and the actual comment.

    When using the query tool, how do i query to show the last comment and last follow up person according to the last date a comment was entered?

    If I use the group by First or Last on Follow up and Comment, I keep getting the first or last by alphabetical order...

    What i want to see is when i run a query where item 37 has four records in the comment table, display 1 record with "Allison" as follow up person and "GEO..." as comment.



    Click image for larger version. 

Name:	Foto.png 
Views:	13 
Size:	15.0 KB 
ID:	11640

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Be careful with Last and First, Max and Min are usually safer.

    If you want to return the entire record this requires either DMax() or intermediate query.

    SELECT * FROM tablename WHERE CM_Last_Update_Date = DMax("CM_Last_Update_Date", "tablename", "CM_Claims_ID=" & [CM_Claims_ID]);

    or

    A simple aggregate query will return the latest date for each ID.
    SELECT CM_Claims_ID, Max(CM_Last_Update_Date) AS LatestDate FROM tablename GROUP BY CM_CLAIMS_ID;

    Now join that query to the table and apply criteria to the CM_Last_Update_Date field:
    = [LatestDate]

    or

    review http://allenbrowne.com/subquery-01.html especially the example for Top N Records Per Group
    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
    andresdm is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    6
    I think it worked!! I'll keep testing but it's looking good! Thank you.

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

Similar Threads

  1. Parent Item / Child Item Not Saving Correctly Together
    By Evilferret in forum Programming
    Replies: 6
    Last Post: 08-24-2012, 02:30 PM
  2. Replies: 7
    Last Post: 10-25-2011, 08:32 PM
  3. Searching Question
    By Jbelle7435 in forum Programming
    Replies: 5
    Last Post: 05-15-2011, 07:48 AM
  4. Searching in the form
    By seeter in forum Forms
    Replies: 11
    Last Post: 08-10-2010, 08:37 AM
  5. Advanced Searching
    By mbolster in forum Forms
    Replies: 3
    Last Post: 07-06-2010, 10:10 AM

Tags for this Thread

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