Results 1 to 4 of 4
  1. #1
    stevo6mm is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    2

    How to select first record based on a field bu include auto gen PK in results.

    Hi there.

    I have a table with data as follows:

    ID |Name |Role |Start Date


    ----------------------------------
    1 |Mr A |Role 1 |01/01/2012
    2 |Mr B |Role 1 |01/02/2012
    3 |Mr C |Role 2 |01/01/2012
    4 |Mr D |Role 2 |01/02/2012
    5 |Mr E |Role 3 |01/01/2012
    6 |Mr F |Role 3 |01/02/2012

    Where ID is an auto-generated number.

    I am trying to select only the most recent entry for each role. I need to ensure I get the ID field in the result as I need to process the record further. The 'Group By - First' feature in access query builder is not suitable as it treats the ID of each reacord as a unique identifier and hence returns every record in the table.

    Your help appreciated.

    Regards

    Steve

  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
    stevo6mm is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    2
    Yep. I reckon that'll do nicely. Thanks very much.

    Steve

  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
    No problem, and welcome to the site by the way.
    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. Replies: 8
    Last Post: 07-06-2013, 05:13 PM
  2. Include Results with Null or Zero
    By emarkman10 in forum Queries
    Replies: 2
    Last Post: 08-07-2012, 06:14 AM
  3. Query results to include descriptions
    By funkygoorilla in forum Queries
    Replies: 4
    Last Post: 02-07-2012, 11:07 AM
  4. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  5. Select a certain field of a record based on ID
    By cesarone82 in forum Access
    Replies: 3
    Last Post: 06-06-2009, 01:16 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