I have run into a frustrating problem I can't make any sense of. I have a query that joins 3 tables. It works fine when the first table is an Access table, but throws an error message when I change the first table to a linked table (SQL Server). The second two tables are always linked tables and there is no problem. The odd part is the error message only references the third table, which I am not changing at all. Can anyone shed some light on this?
QUERY:
Works perfectly when ORDERS is a local table, and INVENTORY and ORDLINE are linked tables. Breaks as soon as I convert ORDERS to linked table.
ERROR MSG (only references INVENTORY table which is not changing):
QUERY:
Works perfectly when ORDERS is a local table, and INVENTORY and ORDLINE are linked tables. Breaks as soon as I convert ORDERS to linked table.
Code:
SELECT INVENTORY.item_no, Sum(ORDLINE.qty_to_ship) AS num_sold
FROM (dbo_oehdrhst_sql AS ORDERS LEFT JOIN dbo_oelinhst_sql AS ORDLINE ON (ORDERS.ord_no = ORDLINE.ord_no) AND (ORDERS.ord_type = ORDLINE.ord_type) AND (ORDERS.inv_no = ORDLINE.inv_no))
LEFT JOIN dbo_iminvloc_sql AS INVENTORY ON (ORDLINE.item_no = INVENTORY.item_no) AND (ORDLINE.loc = INVENTORY.loc)
WHERE ORDERS.inv_dt >= DateSerial(Year(Date())-1,Month(Date()),Day(Date())) And ORDERS.inv_dt <= Date() AND INVENTORY.prod_cat="PTS"
GROUP BY INVENTORY.item_no;
ERROR MSG (only references INVENTORY table which is not changing):
Code:
ODBC--call failed.
[Microsoft][ODBC SQL Server Driver][SQL Server]The multi-part identifier "INVENTORY.prod_cat" could not be bound. (#4104)
[Microsoft][ODBC SQL Server Driver][SQL Server]The multi-part identifier "INVENTORY.loc" could not be bound. (#4104)
[Microsoft][ODBC SQL Server Driver][SQL Server]The multi-part identifier "INVENTORY.item_no" could not be bound. (#4104)