Results 1 to 6 of 6
  1. #1
    DDP123 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2016
    Posts
    2

    Trying to pull first record from groups that are in a field.

    I am somewhat new and am having trouble pulling the data I want. I have multiple records where I am wanting to pull the first record from each group. If I group together the fields than I will group my field on left together where I will show the earliest date for each code and I dont want to do that. I just want the first record from the group. Example of data below.

    Code Date PART CD


    411 20001031 blank
    411 20010101 S09
    412 20010201 C12
    412 20010701 S14
    412 20010801 S09
    412 20030701 C65
    412 20040501 R20
    411 20040510 C06
    411 20040516 C65
    411 20041110 C05
    412 20050216 A10
    412 20050301 Blank
    412 20050816 C05
    412 20061101 C64

    Basically what I am trying to accomplish from the data above is below. Is this even possible? I have tried everything from group to putting fields together and I cant get what I want.

    Code Date PART ID
    411 20001031 blank
    412 20010201 C12
    411 20040510 C06
    412 20050216 A10

    Thanks for your help!

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,934
    in databases there is no such thing as first, last, next or previous without an order of some sort. When new records are added, they do not go 'at the end' or 'last'.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Records in a table do not have a 'natural' order. Sort criteria determines order. This means what is the 'first' or 'last' record is dynamic. What rule determines 'first' record for you - the earliest date? Here is one method http://allenbrowne.com/subquery-01.html#TopN
    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.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    MS Access does not recognize "first" in the same way we do. For Access to know what you mean by "first" you have to tell it what the order of the records is, i.e. how they are sorted. It has no concept of "record number" (unless that is actually in the data).

    The example list you have shown is ordered by date, but if you were to put that in an Access table with no indexes defined, it might show you the records in the order they were entered, but there is no guarantee of that.

    So, without more data in the table, Access cannot do what you want it to in this case.

  5. #5
    DDP123 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2016
    Posts
    2
    Thanks for the reply. Would this be possible in SSRS?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    It should. Assuming SSRS reporting can be based on queries.
    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.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-31-2015, 10:38 PM
  2. Replies: 2
    Last Post: 11-26-2014, 10:04 AM
  3. Replies: 1
    Last Post: 04-07-2014, 04:20 PM
  4. Replies: 1
    Last Post: 08-01-2012, 12:50 AM
  5. Replies: 5
    Last Post: 12-22-2011, 11:01 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