Results 1 to 4 of 4
  1. #1
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101

    Filter Query by earliest date per combination of two columns

    Hello all,



    so I have a table tblCertifications with Columns FullName ; Station ; CertDate ; Status

    Since this table keeps historical records, you can find combinations of FullName and Station multiple times but with different CertDate each

    So I have two doubts:


    • How can I make a query that filters only the most recent date of each combination of columns "FullName" and "Station"?



    • In form frm30, how can I use the textbox txtOperator and selection on listbox lstStation to lookup in that query and display(without clicking any button):
      • The value in status column in txtStatus
      • The value in CertDate column in txtLast

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	8 
Size:	63.1 KB 
ID:	27180

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    How can I make a query that filters only the most recent date of each combination of columns "FullName" and "Station"?
    You would do this using an Aggregate (Totals) query.

    1. Create a new query
    2. Only add the following fields: FullName, Station, CertDate
    3. Click on the Totals button (looks like a Sigma) - this will add a new Totals Row to each field, and each will have a value of "Group By" under it
    4. Change the Totals Row setting under the CertDate field from "Group By" to "Max"
    5. View your results

    This should give you what you want.

  3. #3
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101
    Quote Originally Posted by JoeM View Post
    You would do this using an Aggregate (Totals) query.

    1. Create a new query
    2. Only add the following fields: FullName, Station, CertDate
    3. Click on the Totals button (looks like a Sigma) - this will add a new Totals Row to each field, and each will have a value of "Group By" under it
    4. Change the Totals Row setting under the CertDate field from "Group By" to "Max"
    5. View your results

    This should give you what you want.
    Excellent, that works perfectly.

    Now I only have the second doubt to clear up

  4. #4
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    101
    So I figured the second doubt out and if it's good for anyone, this is the working code:

    Code:
    =DLookUp("[Status]","[Qry-CertStat]","([Estación]='" & [Forms]![frm20MainStatus]![cmbStation] & "') And ([Operador]='" & [Forms]![frm20MainStatus]![lstDesig] & "')")

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

Similar Threads

  1. Replies: 3
    Last Post: 04-12-2016, 07:15 AM
  2. Replies: 4
    Last Post: 02-25-2016, 08:18 AM
  3. select the 2 earliest date records for each id
    By lbrannon in forum Queries
    Replies: 10
    Last Post: 07-14-2015, 04:10 PM
  4. Replies: 3
    Last Post: 04-19-2013, 12:49 PM
  5. Replies: 1
    Last Post: 02-17-2012, 04:43 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