Results 1 to 3 of 3
  1. #1
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659

    Two Queries but only one works for me

    I made this query. Drives the input functions for order manipulation. The First one works as intended. No issues, the second one. I cannot get to work ambiguous query but I setup the same was as the first AFAIK. I need the 2nd one to be editable, the first one is. Do you see my problem? Both of these were made with the designer.



    Query 1
    Code:
    SELECT tblRegions.Location, tblSalesOrders.SalesOrderID, tblCustomerShipTo.SiteName, tblSalesOrdersInventoryLineItems.LineNumber, tblPartMaster.LongDescription, tblWorkOrders.Status, tblSalesOrdersInventoryLineItems.Qty, tblSalesOrdersInventoryLineItems.DrawingNumber, tblPartMaster.DrawingNumber, Year([PrintedDate]) AS PrintedYear, tblSalesOrders.DatePromised, tblSalesOrders.RevisionNumber, tblPartMaster.PartNumber, tblSalesOrders.PrintedDate
    FROM tblWorkOrders RIGHT JOIN (((tblSalesOrders INNER JOIN (tblPartMaster INNER JOIN tblSalesOrdersInventoryLineItems ON tblPartMaster.PartNumber = tblSalesOrdersInventoryLineItems.PartNumber) ON tblSalesOrders.SalesOrderID = tblSalesOrdersInventoryLineItems.SalesOrderID) INNER JOIN tblCustomerShipTo ON (tblSalesOrders.SiteID = tblCustomerShipTo.SiteID) AND (tblSalesOrders.CustomerID = tblCustomerShipTo.CustomerID)) INNER JOIN tblRegions ON tblCustomerShipTo.Region = tblRegions.ID) ON (tblWorkOrders.[Sales Order Li] = tblSalesOrdersInventoryLineItems.LineNumber) AND (tblWorkOrders.[Sales Order] = tblSalesOrdersInventoryLineItems.SalesOrderID)
    WHERE (((Year([PrintedDate]))>=Year(Now())+CInt(DLookUp("[Property Value]","tblSettings","[Property Name]='SalesOrderDateWindow'"))))
    ORDER BY Year([PrintedDate]) DESC , tblSalesOrders.PrintedDate DESC;

    Query 2
    Code:
    SELECT tblRegions.Location, tblStockXfersInventoryLineItems.LineNumber, tblPartMaster.LongDescription, tblStockXfersInventoryLineItems.WorkOrderStatus, tblStockXfersInventoryLineItems.Qty, tblStockXfersInventoryLineItems.DrawingNumber, tblPartMaster.DrawingNumber, Year([PrintedDate]) AS PrintedYear, tblPartMaster.PartNumber, tblLoc.LocDesc, tblStockXfersInventoryLineItems.StockXferID, tblPartMaster.LongDescription, tblStockXfers.PrintedDate, tblStockXfers.RequestedShipDate, tblStockXfers.RevisionNumber
    FROM ((((tblPartMaster INNER JOIN tblStockXfersInventoryLineItems ON tblPartMaster.PartNumber = tblStockXfersInventoryLineItems.PartNumber) INNER JOIN tblStockXfers ON tblStockXfersInventoryLineItems.StockXferID = tblStockXfers.StockXferID) INNER JOIN tblLoc ON tblStockXfers.ToLocID = tblLoc.LocID) INNER JOIN tblRegions ON tblLoc.Region = tblRegions.ID) INNER JOIN tblWorkOrders ON (tblWorkOrders.[Sales Order Li] = tblStockXfersInventoryLineItems.LineNumber) AND (tblStockXfersInventoryLineItems.StockXferID = tblWorkOrders.[Sales Order])
    WHERE (((Year([PrintedDate]))>=Year(Now())+CInt(DLookUp("[Property Value]","tblSettings","[Property Name]='SalesOrderDateWindow'"))))
    ORDER BY Year([PrintedDate]) DESC , tblStockXfers.PrintedDate DESC;

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    It's always difficult to see in a large query string, but your initial join is an Inner join in the second query as a opposed to a Right Join in the first one...

    Generally Inner joins render queries uneditable.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Just noticed that as well. Good point

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

Similar Threads

  1. Replies: 1
    Last Post: 06-21-2015, 07:58 AM
  2. Replies: 9
    Last Post: 08-27-2014, 11:34 AM
  3. Is this how a combobox works?
    By crobaseball in forum Access
    Replies: 3
    Last Post: 04-09-2014, 12:49 AM
  4. One works, the other doesn't. Why?
    By oleBucky in forum Queries
    Replies: 6
    Last Post: 05-09-2011, 01:52 PM
  5. Ensuring Everything Works...?
    By catat in forum Access
    Replies: 1
    Last Post: 03-31-2010, 01:44 PM

Tags for this Thread

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