Results 1 to 8 of 8
  1. #1
    sseniour is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    10

    Lookup Question

    What is best way to accomplish result?


    Table A SUPPLIER DOCK ORDER NO
    12345 XX 20250606
    Table B SUPPLIER DOCK ORDER NO LOG_PT LOCAL_DT
    12345 XX 20250606 8888PYD 5/30/25 16:34
    12345 XX 20250606 8888P 6/4/25 9:15
    Result
    SUPPLIER DOCK ORDER NO ARR UNL
    12345 XX 20250606 5/30/25 16:34 6/4/25 9:15

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,818
    Hi
    Can you upload a screenshot of your relationships?

    Or better still the actual database.

  3. #3
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    299
    How do you know which record in Table B holds the "ARR" and which holds the "UNL"?
    Is it the "PYD" part of LOG_PT?
    Groeten,

    Peter

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Will there be only 2 Table B records for each order?

    From the example data, you want Min(LOCAL_DT) AS ARR and Max(LOCAL_DT) AS UNL for each order. This would be accomplished in an aggregate (GROUP BY) query.

    Are you really duplicating Suppler, Dock, Order No into Table B?
    Last edited by June7; 06-06-2025 at 10:20 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    430
    as suggested you create a Query against Table B:
    Code:
    SELECT SUPPLIER, DOCK [ORDER NO], MIN(LOG__PT) AS LOGPT,  MAX(LOCAL_DT) AS LOCALDT FROM [TABLE B] ORDER BY SUPPLIER, DOCK, [ORDER NO];

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    jojo, almost - consider:

    SELECT SUPPLIER, DOCK, [ORDER NO], MIN(LOCAL_DT) AS ARR, MAX(LOCAL_DT) AS UNL FROM [TABLE B] GROUP BY SUPPLIER, DOCK, [ORDER NO];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    sseniour is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    10
    Yes "8888PYD" would be the ARR time.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    On my phone so can’t provide the sql but you could join table a to table b on order no or perhaps supplier and order no. Otherwise, what is the purpose of table a?

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

Similar Threads

  1. Lookup values not appearing in Lookup field?
    By dominover in forum Access
    Replies: 4
    Last Post: 03-05-2016, 05:01 PM
  2. Replies: 4
    Last Post: 07-28-2015, 10:14 AM
  3. Replies: 3
    Last Post: 05-08-2015, 11:08 AM
  4. Replies: 5
    Last Post: 11-24-2014, 02:19 PM
  5. Replies: 5
    Last Post: 06-25-2014, 09:19 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