Results 1 to 2 of 2
  1. #1
    ThomasLonsdale is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2015
    Posts
    3

    Query matching products sent and received

    Hi. I have two tables that I want to match records against one another in a unique way so that the query produces a result showing me all the remaining records that are unmatched i.e. I want to quickly find any products that have been sent but not returned.



    The first table contains the relevant sent information:

    Sent Date | Product ID | Company | Comments

    The second table contains relevant received information:

    Received Date | Product ID | Company | Comments

    What I want to do is match records in a chronological way so that if for example we had the following events:

    Sent 01/01/2015 Product #1
    Received 02/01/2015 Product #1

    Sent 05/01/2015 Product #1
    Received 06/01/2015 Product #1

    Sent 08/01/2015 Product #1

    The query would match events and display the single last event which has no matching received record (no later return date). I've spent some time on this and I've had some progress but my biggest problem is that my SQL code doesnt match my records such that it pairs Product ID AND obeys the condition that the received date is later than the sent date.

    Excuse my poor table/field names as this was my first attempt at a MS access database but currently my SQL code looks like this:

    SELECT [New Entry].[Sent Date], [New Entry].Dolavs.Value, [New Entry].Company, [New Entry].Comments, [Received Dolavs].[Received Date], [Received Dolavs].Dolavs.Value, [Received Dolavs].Company, [Received Dolavs].Comments


    FROM [New Entry] LEFT JOIN [Received Dolavs] ON [New Entry].Dolavs.Value = [Received Dolavs].Dolavs.Value


    WHERE [Received Dolavs].[Received Date] Is Null;

    Which gives me exactly what I need EXCEPT it doesn't discriminate the condition required that we only want to match records where the Sent Date is less than the Received date which should leave any records where there is a sent date that is later than any records received dates.

    Thanks for your help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe you can create an alias and include an IIf() function. Something like
    MyAlias: IIf([Sent Date] < [Received Date], 1, 0)

    Add a criteria to your alias
    >0

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

Similar Threads

  1. Replies: 5
    Last Post: 07-10-2014, 09:37 AM
  2. Invoice and payments received
    By esther6086@lowcountry.com in forum Queries
    Replies: 1
    Last Post: 08-13-2013, 06:28 PM
  3. Replies: 8
    Last Post: 04-24-2012, 01:05 PM
  4. Query for Received and Closed Date Range
    By swalsh84 in forum Queries
    Replies: 2
    Last Post: 10-11-2011, 09:06 AM
  5. 3464 error received
    By TEN in forum Programming
    Replies: 10
    Last Post: 07-08-2009, 07:25 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