Results 1 to 7 of 7
  1. #1
    suprdave is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    8

    Need help creating a data query to eliminate irrelevent data

    Hello all,



    Please bear with me as I'm new to Access queries. I am trying to eliminate irrelevant data. Here's the scenario.

    Table name = ColorChoice

    Field 1 = RequestDate
    Field 2 = RequestName
    Field 3 = Color
    Field 4 = LogEntry (time record was created)

    Fields 1 and 2 may have duplicate data, but fields 3 and 4 will contain different data for each combination.

    How can I display only the last record for each set based on newest LogEntry for each set?

    The column containing "show" was added to demonstrate which record should output from my query.

    RequestDate RequestName Color LogEntry
    1/1/2016 Ted Red 12/28/2015 20:15
    1/1/2016 Ted Green 12/29/2015 08:13
    1/1/2016 Ted Blue 12/29/2015 10:04 Show
    1/1/2016 Jim Red 11/16/2015 07:14
    1/1/2016 Jim Green 11/18/2015 09:30 Show
    1/2/2016 Wendy Red 10/31/2015 12:15 Show
    1/2/2016 Nancy Red 9/18/2015 09:26 Show
    1/3/2016 Ted Red 1/1/2016 19:45 Show
    1/4/2016 Dave Red 12/30/2015 08:17
    1/4/2016 Dave Green 12/31/2015 14:55 Show

    Thanks,

    Dave
    Last edited by suprdave; 01-19-2016 at 08:46 AM.

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    One way is to do this is a set of two queries (or a single nested query).

    First, create an Aggregate Query, where you just have three fields: RequestDate, RequestName, and LogEntry.
    When you click on the Totals button (looks like a Sigma), it will add a Totals row under each field. Leave the values as "Group By" for the first two fields, but change the value for LogEntry to Max. This will return the latest LogEntry for each RequestDate/RequestName combination.

    Now, create a second query where you join your original table to the Aggregate Query you created above, joining on ALL three fields. You can then return any/all of the fields from the original table that you want to display, and it should see that it will only return the records you listed above in your example.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    suprdave,

    Can you give us an overview description of the "business" your database is intended to support? Getting your tables and relationships to match your business is key to database.

  4. #4
    suprdave is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    8
    This database will feed data to a web calendar displaying employee time-off requests. The source data is a log file from our payroll provider.

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Did you try my suggestion?

  6. #6
    suprdave is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    8
    Looking at it now. Thanks for the fast response. Will report my results shortly.

  7. #7
    suprdave is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    8
    Thanks JoeM!
    That did the trick.
    Dave

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

Similar Threads

  1. Replies: 6
    Last Post: 08-17-2014, 06:14 PM
  2. Replies: 1
    Last Post: 03-17-2014, 12:26 PM
  3. Replies: 27
    Last Post: 08-14-2012, 09:05 AM
  4. Replies: 1
    Last Post: 08-11-2011, 07:36 AM
  5. Eliminate redundant data from Pick Box?
    By jsbdiver in forum Forms
    Replies: 5
    Last Post: 06-14-2010, 04:04 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