Results 1 to 5 of 5
  1. #1
    ejohnso4 is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    7

    Lightbulb How I query for the most recent date for a record?

    Hello. I have an access database that carries medical information on patients. We are wanting to follow these patients and look at a specific lab value (PSA) over time. I have a PSA table, which has the patient's ID number, the date of the PSA, and the PSA value. Each patient might have 4 or 5 PSA values on different dates. I want to query only the most recent PSA value for all of the patients. However, when I try it ends up listing all the PSA values and not just the most recent. Do you have a solution or know a function to help with this? Here is an example of what the table looks like now:

    ID Date PSA Value
    1 1/5/10 4.0
    1 2/2/10 3.0
    1 3/3/10 2.0
    2 1/8/10 8
    2 2/10/10 5


    3 1/1/10 10
    3 2/15/10 2

    All I want is the patient 1 3/3/10 value, the patient 2 2/10/10 value, and patient 3 2/15/10 value- i.e. most recent. I would look at them individually but there are over 1000 patients in the database, so that is not optimal. Any help??
    3
    3

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Dont know why you would use 2 queries. In the dropdown on the design view with Totals activated, leave ID with Group By and choose Max for the Date field. That should suffice, no?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by TheShabz View Post
    Dont know why you would use 2 queries. In the dropdown on the design view with Totals activated, leave ID with Group By and choose Max for the Date field. That should suffice, no?
    That will get you the max date, not the corresponding PSA value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    correct your are sir.

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

Similar Threads

  1. Return most recent entry for each item
    By GenAp in forum Queries
    Replies: 1
    Last Post: 02-04-2010, 05:30 AM
  2. Populate date from previous record
    By Lianes in forum Access
    Replies: 3
    Last Post: 09-19-2009, 03:42 PM
  3. most recent entries
    By tom4038 in forum Queries
    Replies: 0
    Last Post: 09-14-2009, 04:41 AM
  4. Pulling most recent data from child table
    By davidv43 in forum Access
    Replies: 0
    Last Post: 02-07-2009, 11:36 AM
  5. Replies: 1
    Last Post: 09-20-2007, 02:56 PM

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