Results 1 to 12 of 12
  1. #1
    RBTB9 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    6

    Identifying original entry date against multiple records

    Hi,

    I am trying to identify when a patient(PAT_MRN_ID) first was assigned to a Provider(PROV_NAME) by date(EFF_DATE). Most patients have changed providers over and over, so I want to know who the first provider was assigned to a specific patient based on the date(EFF_DATE).
    I have tried using 'First' or "min" in the EFF_DATE field, but I keep getting all records.



    DATA SAMPLE:

    PAT_NAME PAT_ID PCP PROV_NAME EFF_DATE TERM_DATE
    TEST, CUSTOMER 111111 1234 JONES, DAVID 28-AUG-02 03-DEC-07
    TEST, CUSTOMER 111111 5678 DOE, JANE 04-DEC-07 18-MAR-09
    TEST, CUSTOMER 111111 10 NO PCP 19-MAR-09 15-SEP-10
    TEST, CUSTOMER 111111 5678 DOE, JANE 16-SEP-10 22-JUN-11

    I want to be able to just get the record with the oldest EFF_DATE.

  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
    This should get you started:

    http://www.baldyweb.com/LastValue.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    RBTB9 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    6
    Thanks.
    Not much experience in writing SQL.
    Can this be done with an expression and/or criteria?

  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
    Possibly, but it would likely be more complicated and less efficient. You can create it in design view, using the Totals icon.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    RBTB9 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    6
    Sorry for the follow-up question (learning this as I go).

    How would I write this in Design View?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Add those 2 fields to a new query, click on the Totals icon and change the Group By to Min on the appropriate field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    RBTB9 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    6
    I have tried using the Min in the Group By (as well as 'First'), however I keep getting the same set of data.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you have other fields included? Can you post a sample db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    RBTB9 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    6
    Here is my attempt at SQL.
    SELECT dbo_patient.pat_name, dbo_pat_pcp.pat_mrn_id=123456, dbo_pat_pcp.pcp_prov_id, dbo_clarity_ser.prov_name, Min([eff_date])from[dbo_pat_pcp], dbo_pat_pcp.term_date, dbo_date_dimension.month_Name, dbo_date_dimension.Year

    Getting error that pathway could not be found

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    SELECT pat_mrn_id, Min([eff_date]) As MinDate
    FROM dbo_pat_pcp
    GROUP BY pat_mrn_id
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    RBTB9 is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    6
    I tried that and I am now getting an ODBC error. Query that I had previously built still working.
    Question: How would I add in the other fields for the report once I get the first part working?

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You would join that query in another query, as shown on the link.
    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: 17
    Last Post: 01-29-2012, 01:28 PM
  2. Identifying the first entry
    By HelenP in forum Access
    Replies: 8
    Last Post: 10-20-2010, 08:31 PM
  3. Edit record in form with original entry shown
    By erknoebe in forum Access
    Replies: 5
    Last Post: 09-29-2010, 02:33 PM
  4. Replies: 0
    Last Post: 07-26-2010, 07:34 AM
  5. Report to display multiple records by date.
    By af01waco in forum Reports
    Replies: 1
    Last Post: 03-21-2009, 02:12 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