Results 1 to 7 of 7
  1. #1
    jbailey4545 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    14

    Select newest Record

    I need some help selecting the newest patient record in a table. The problem is that each patient could have multiple entries in the table. The way to identify the new record is by the highest program_seq number. Example below.



    Click image for larger version. 

Name:	example.jpg 
Views:	8 
Size:	11.7 KB 
ID:	8199

    I want the third row to be the only one that shows in the query.

  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
    Did you forget about this thread?

    https://www.accessforums.net/queries...elp-25854.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jbailey4545 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    14
    I tried that. Still ended up with duplicate patient records.

  4. #4
    jbailey4545 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    14
    You might know if this is possible. I have did code a while back in a program that would look through the table and kick out duplicates. For example if you sort the query by client_id then program_seq. It would start at program_seq : 1 then look at the next record. If the client_id was = to the next record client_id it would then compare the 2 program_seq numbers and take the larger of the two. Once the next record client_id changed it kept the last record for the last client with the highest program_seq number. Anything like that possible in Access?

  5. #5
    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 jbailey4545 View Post
    I tried that. Still ended up with duplicate patient records.
    With my method? Post the SQL you used, as you shouldn't get duplicates with mine.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    jbailey4545 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    14
    I just re created the new query and you are right. I must have missed something when i did it before. Thank you for your help.

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

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

Similar Threads

  1. Newest dates based on criteria
    By benjammin in forum Queries
    Replies: 13
    Last Post: 05-15-2012, 02:49 PM
  2. select Subform record and go to record on form
    By pcool in forum Programming
    Replies: 6
    Last Post: 04-16-2012, 05:50 PM
  3. Display newest of two fields (one Max, one Min)
    By cherithmoore in forum Queries
    Replies: 7
    Last Post: 12-16-2011, 02:50 PM
  4. Aqtualization to the newest query
    By City73 in forum Queries
    Replies: 3
    Last Post: 10-30-2010, 07:18 PM
  5. Query From Newest Date
    By SSgtJ in forum Queries
    Replies: 2
    Last Post: 01-21-2010, 01:51 PM

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