Results 1 to 3 of 3
  1. #1
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53

    Query not doing what I want it to

    I now have another issue



    So I have a table:

    ShipDeliveryDates
    ID (Primary Key)
    Project_Number
    Component_Number
    Sched_Ship_Date
    Sched_Delivery_Date


    Click image for larger version. 

Name:	image.png 
Views:	8 
Size:	8.1 KB 
ID:	16578


    And I had wanted to create a query to get all the current dates for each project. I had wanted both the 'upcoming' Sched_Ship_Date and the 'upcoming' Sched_Delivery_Date relative to today's date for each project.The query below only works when you don't try to get both the current Sched_Ship_Date and the Sched_Delivery_Date at the same time (works if ignoring one of the two). I can understand what is causing this problem by reading the query but I can't come up with the solution to make the query below work like I want it to.

    Query

    SELECT ShipDeliveryDates.Project_Number, Min(ShipDeliveryDates.Sched_Ship_Date) AS Sched_Next_Ship_Date, Min(ShipDeliveryDates.Sched_Delivery_Date) AS Sched_Next_Delivery_Date
    FROM ShipDeliveryDates
    WHERE (((ShipDeliveryDates.Sched_Ship_Date)>=Date()) And ((ShipDeliveryDates.Sched_Delivery_Date)>=Date()))
    GROUP BY ShipDeliveryDates.Project_Number;

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Options:

    1. two queries to retrieve the two dates then join the queries in a third query

    2. domain aggregate function (DLookup, DSum, DAvg, DMin, etc), beware - these functions can perform slowly in queries and on forms/reports; I presume you have a table of unique project numbers called maybe Projects

    SELECT Project_Number,
    DMin("Sched_Ship_Date", "ShipDeliveryDates", "Project_Number=" & [Project_Number] & " AND Sched_Ship_Date>=Date()") AS Sched_Next_Ship_Date,
    DMin("Sched_Delivery_Date", "ShipDeliveryDates", "Project_Number=" & [Project_Number] & " AND Sched_Delivery_Date>=Date()") AS Sched_Next_Delivery_Date
    FROM Projects;
    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.

  3. #3
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by June7 View Post
    Options:

    1. two queries to retrieve the two dates then join the queries in a third query

    2. domain aggregate function (DLookup, DSum, DAvg, DMin, etc), beware - these functions can perform slowly in queries and on forms/reports; I presume you have a table of unique project numbers called maybe Projects

    SELECT Project_Number,
    DMin("Sched_Ship_Date", "ShipDeliveryDates", "Project_Number=" & [Project_Number] & " AND Sched_Ship_Date>=Date()") AS Sched_Next_Ship_Date,
    DMin("Sched_Delivery_Date", "ShipDeliveryDates", "Project_Number=" & [Project_Number] & " AND Sched_Delivery_Date>=Date()") AS Sched_Next_Delivery_Date
    FROM Projects;
    Wow I never thought about merging two queries together, thank you so much for your help.

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

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