Results 1 to 4 of 4
  1. #1
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    73

    Retrieve the last record in a table

    Good day all,
    I have an access table with Vehicle registration numbers and checklist dates. There are multiple records of the same vehicle registration number, but each record has a unique date. See below:


    Click image for larger version. 

Name:	Image 1.jpg 
Views:	18 
Size:	29.7 KB 
ID:	50434

    I only want to see record 1 and 3.
    I tried DFirst, DLast and had a look at several suggestions on the forums, but none is giving me the results I am looking for.

    I do not know beforehand what the registration numbers will be. I need to retrieve those registration numbers by retrieving the last date captured for each registration number.

    Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,010
    Use Dmax() on the date and group by reg number.

    Edit: Sorry I meant Max()
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,046
    select max(MyDatefield) from MyTableName group by MyRegNumberField
    If you want to see all data fields connected to this combination: save the groupsquery and use it in a second query linked to the Vehicle registrations table on the regnumber field + date field

  4. #4
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    73
    Thanks a lot - solved!

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

Similar Threads

  1. Replies: 4
    Last Post: 10-13-2021, 01:14 PM
  2. Replies: 4
    Last Post: 09-13-2017, 10:35 AM
  3. Replies: 4
    Last Post: 04-22-2016, 02:23 PM
  4. Replies: 2
    Last Post: 07-09-2013, 12:22 PM
  5. Replies: 1
    Last Post: 12-09-2011, 08:14 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