Results 1 to 3 of 3
  1. #1
    wizzz_wizzz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    14

    Find the Nearest Date from another table

    Hi All,

    I have a table tblSPM in which the field [Supplier_Delivery_Date] is updated frequently. On another table - tblShipmentDates,
    I have a field [Shipment_Dates], which is a list of schedule to make shipment to customers.

    Basically, I need a query to find the next nearest date (from Shipment_Dates], depending on [Supplier_Delivery_Date].

    Can someone point me to the right direction how can I go about doing it?




    Appreciate any advise. Thank you!
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    in a query, join the 2 tables on the CustID field.
    bring down dates from both tables, and create a field" 'difference' to calc the #days between them.

    difference:=DateDiff("d",tSPM.Supplier_Delivery_Da te, tblShipmentDates.Shipment_Dates)

    sort the results ASC. These are the dates closest. (smallest difference)

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    If that doesn't work for you because of table design or whatever, it should be possible by creating a query with a subquery. Basically, the sub query gets the nearest date (less or greater than depending on the expression used) as long as there's at least one common field between the two tables. If the topic of sub queries is new to you, check this out
    http://allenbrowne.com/subquery-01.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-17-2017, 08:52 AM
  2. Replies: 10
    Last Post: 05-15-2015, 11:35 AM
  3. Replies: 8
    Last Post: 10-29-2014, 04:51 AM
  4. Find nearest location
    By wnicole in forum Access
    Replies: 14
    Last Post: 05-12-2014, 11:37 AM
  5. Find the Nearest Previous Saturday
    By RachelBedi in forum Access
    Replies: 1
    Last Post: 09-21-2012, 12:51 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