Results 1 to 6 of 6
  1. #1
    Ronald Burke is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    3

    Query A specified date range for each customer

    My database is designed to register complaints (for lack of a better word). I have a table for the initial complaint entry. I have a second table for follow-up notes. The criteria for the follow up notes is date of entry, person who entered and the note. I want to be able to run a query that will show me only the 3 most recent dates/notes for each registerd complaint. I tried to use a Min Max Totals query but the results I get are for the top 3 dates for the entire follow-up notes table. I need the top 3 dates for each complaint registered not overall. Any suggestions?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    make 2 queries:

    make Q1 to get the dates, turn on Grouping summation, and use TOP 3 property:
    select TOP 3 PersonID, Max(Date) from table where PersonID = forms!myform!cboPerson

    Q2:
    that gets you the recent Dates, so now join your data table to Q1 to get all the data:
    select * from tData,Q1 where tData.PersonID = Q1.PersonID

    if the PersonID is chosen from a form,
    run Q2.

  3. #3
    Ronald Burke is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    3
    ranman256 thank you for the information. Unfortunately, I am not an advanced user so I'm not clear on how to proceed.

    Complaint table has REQID (means request ID), Follow-Up Table as follow-Up date. If I turn on the grouping in the query for the date, I get a result that show the top 3 follow-up entries in the follow-up table. I want the system to tell me what the top 3 follow-up entries are for each REQID in the complaint table.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    thats more complicated. Without a lot of VB, you could do this:
    a form with a listbox of all the ReqID.
    select 1st one,

    run Q2, where Q1 looks at the item selected
    select TOP 3 ReqD, Max(Date) from table where ReqID = forms!myform!lstReq
    Q2 would be an append query to add the results to a 'report' table,

    move to next ReqID, run Q2 again
    until all ReqID in list have run.




  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Need more info.
    You said:
    Quote Originally Posted by Ronald Burke View Post
    I have a table for the initial complaint entry. I have a second table for follow-up notes.
    How are the two tables related?



    See: TOP n records per group

  6. #6
    Ronald Burke is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    3
    Thank you everyone for your advice and assistnace. I was able to get it to work.

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

Similar Threads

  1. Replies: 17
    Last Post: 07-31-2018, 01:23 PM
  2. Replies: 7
    Last Post: 11-03-2016, 07:59 PM
  3. Replies: 3
    Last Post: 01-26-2016, 01:56 PM
  4. Replies: 6
    Last Post: 12-11-2013, 09:27 PM
  5. Date Range Query
    By need_help12 in forum Queries
    Replies: 7
    Last Post: 04-25-2012, 01:38 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