Results 1 to 2 of 2
  1. #1
    kwilliams5675 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    3

    Query using historical table

    I am running a query with two tables:



    1. Historical table of status codes and date status code changed.
    2. Dataset of records.

    I want to return only the records that have are currently sitting at an O status and exclude them if they have an S status..

    Example:

    Record 12345 was on O status on 03/13/2009 and changed to an S status on 06/26/2010... If it changed to an S status, I want to exclude that record from my dataset.

    What criteria would be used to accomplish this?

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    First, build a query [qryMaxStatusDate] from your historical table that returns only the recordID and the statusdate fields. Set the recordID to "Group By" and the statusdate to "MAX".

    Second, build another query [qryCurrentStatus] that joins the historical table with your [qryMaxStatusDate] on the recordID and the StatusDate - MaxOfStatusDate. Return everything from the historical table.

    Finally, Build a third query [qryCurrentRecordStatus] that joins your "dataset of records" with [qryCurrentStatus] on the recordID. Add a criteria to the status field of "O".

    Cheers,

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

Similar Threads

  1. Edit a table in a query by renaming the query?
    By TheWolfster in forum Queries
    Replies: 2
    Last Post: 07-30-2010, 02:57 PM
  2. Replies: 1
    Last Post: 07-30-2010, 10:28 AM
  3. Replies: 2
    Last Post: 03-14-2010, 07:27 PM
  4. Replies: 0
    Last Post: 02-24-2010, 12:56 AM
  5. Replies: 2
    Last Post: 10-27-2009, 07:09 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