asked on
SELECT tmpQuery2.DivisionName, tmpQuery2.ProjectName, tmpQuery2.Type,
tmpQuery2.tmpShipping.StoreNumber, tmpQuery2.tmpShipping.Shipment,
Dconcat("tmpShipping.Category","tmpQuery2","[tmpShipping].[Shipment] = '" &
[tmpShipping].[Shipment] & "' And [tmpShipping].[StoreNumber] = " &
[tmpShipping].[StoreNumber]) AS Category, tmpQuery2.tmpShipping.Mode,
tmpQuery2.tmpShipping.ActSailDate, tmpQuery2.tmpShipping.EstArrivalDate,
tmpQuery2.tmpShipping.ActArrivalDate, tmpQuery2.tmpShipping.Signature,
tmpQuery2.Shipping.StoreNumber, tmpQuery2.Shipping.Shipment,
tmpQuery2.Shipping.Mode, tmpQuery2.Shipping.ActSailDate,
tmpQuery2.Shipping.EstArrivalDate, tmpQuery2.Shipping.ActArrivalDate,
tmpQuery2.QtyReceived, tmpQuery2.Shipping.Signature
FROM tmpQuery2
GROUP BY tmpQuery2.DivisionName, tmpQuery2.ProjectName, tmpQuery2.Type,
tmpQuery2.tmpShipping.StoreNumber, tmpQuery2.tmpShipping.Shipment,
Dconcat("tmpShipping.Category","tmpQuery2","[tmpShipping].[Shipment] = '" &
[tmpShipping].[Shipment] & "' And [tmpShipping].[StoreNumber] = " & [tmpShipping].[StoreNumber]),
tmpQuery2.tmpShipping.Mode, tmpQuery2.tmpShipping.ActSailDate,
tmpQuery2.tmpShipping.EstArrivalDate, tmpQuery2.tmpShipping.ActArrivalDate,
tmpQuery2.tmpShipping.Signature, tmpQuery2.Shipping.StoreNumber,
tmpQuery2.Shipping.Shipment, tmpQuery2.Shipping.Mode, tmpQuery2.Shipping.ActSailDate,
tmpQuery2.Shipping.EstArrivalDate, tmpQuery2.Shipping.ActArrivalDate,
tmpQuery2.QtyReceived, tmpQuery2.Shipping.Signature
ORDER BY tmpQuery2.DivisionName, tmpQuery2.Type,
tmpQuery2.tmpShipping.StoreNumber, tmpQuery2.tmpShipping.Shipment;
ASKER
SELECT Projects.DivisionName, Projects.ProjectName, IIf(IsNull([Shipping].[ID]),"New","Update") AS Type, tmpShipping.StoreNumber, tmpShipping.Shipment, tmpShipping.Category, tmpShipping.Mode, tmpShipping.ActSailDate, tmpShipping.EstArrivalDate, tmpShipping.ActArrivalDate, tmpShipping.Signature, Shipping.StoreNumber, Shipping.Shipment, Shipping.Category, Shipping.Mode, Shipping.ActSailDate, Shipping.EstArrivalDate, Shipping.ActArrivalDate, Shipping.QtyReceived, Shipping.Signature
FROM Projects INNER JOIN (tmpShipping LEFT JOIN Shipping ON tmpShipping.TrackerNo = Shipping.TrackerNo) ON Projects.StoreNumber = tmpShipping.StoreNumber
GROUP BY Projects.DivisionName, Projects.ProjectName, IIf(IsNull([Shipping].[ID]),"New","Update"), tmpShipping.StoreNumber, tmpShipping.Shipment, tmpShipping.Category, tmpShipping.Mode, tmpShipping.ActSailDate, tmpShipping.EstArrivalDate, tmpShipping.ActArrivalDate, tmpShipping.Signature, Shipping.StoreNumber, Shipping.Shipment, Shipping.Category, Shipping.Mode, Shipping.ActSailDate, Shipping.EstArrivalDate, Shipping.ActArrivalDate, Shipping.QtyReceived, Shipping.Signature, tmpShipping.ID, Shipping.ID
HAVING (((Shipping.Category)<>[tmpShipping]![Category])) OR (((Shipping.Shipment)<>[tmpShipping]![Shipment])) OR (((Shipping.Mode)<>[tmpShipping]![Mode])) OR (((Shipping.ActSailDate)<>[tmpShipping]![ActSailDate])) OR (((Shipping.EstArrivalDate)<>[tmpShipping]![EstArrivalDate])) OR (((Shipping.ActArrivalDate)<>[tmpShipping]![ActArrivalDate])) OR (((Shipping.Signature)<>[tmpShipping]![Signature])) OR (((Shipping.ID) Is Null));
ASKER
SELECT Projects.DivisionName, Projects.ProjectName, IIf(IsNull([Shipping].[ID]),"New","Update") AS Type,
tmpShipping.StoreNumber, tmpShipping.Shipment, tmpShipping.Category,
tmpShipping.Mode, tmpShipping.ActSailDate, tmpShipping.EstArrivalDate,
tmpShipping.ActArrivalDate, tmpShipping.Signature,
Shipping.StoreNumber, Shipping.Shipment, Shipping.Category,
Shipping.Mode, Shipping.ActSailDate, Shipping.EstArrivalDate,
Shipping.ActArrivalDate, Shipping.QtyReceived, Shipping.Signature
FROM Projects INNER JOIN (tmpShipping
LEFT JOIN Shipping ON tmpShipping.TrackerNo = Shipping.TrackerNo)
ON Projects.StoreNumber = tmpShipping.StoreNumber
WHERE (Shipping.Category<>[tmpShipping]![Category])
OR (Shipping.Shipment<>[tmpShipping]![Shipment])
OR (Shipping.Mode<>[tmpShipping]![Mode])
OR (Shipping.ActSailDate<>[tmpShipping]![ActSailDate])
OR (Shipping.EstArrivalDate<>[tmpShipping]![EstArrivalDate])
OR (Shipping.ActArrivalDate<>[tmpShipping]![ActArrivalDate])
OR (Shipping.Signature<>[tmpShipping]![Signature])
OR (Shipping.ID Is Null);
Next, I see that you are joining Shipping and tmpShipping on the field TrackerNo. Is this a unique key in both tables? If not then you will have trouble because records with one category will not match records with another, and vice-versa.TrackerNo Category
========= ========
1234 C1
1234 C2
These records are the same in both tables, so you should not expect them to turn up in your "differences" query, but they will, because the C1 in one table does not match the C2 in the other. So you will get:
TrackerNo tmpShipping.Category Shipping.Category
========= ==================== =================
1234 C1 C2
1234 C2 C1
Now, I understand you want to select the records where anything including the list of categories has changed. To do this, I think you would be best to compare the concatenated lists, not the individual categories.SELECT DISTINCT
Projects.DivisionName, Projects.ProjectName, IIf(IsNull([Shipping].[ID]),"New","Update") AS Type,
tmpShipping.StoreNumber, tmpShipping.Shipment,
DConcat("Category","tmpShipping","[TrackingNo]=" & [tmpShipping].[TrackingNo]) AS tmpShippingCategory,
tmpShipping.Mode, tmpShipping.ActSailDate, tmpShipping.EstArrivalDate,
tmpShipping.ActArrivalDate, tmpShipping.Signature,
Shipping.StoreNumber, Shipping.Shipment,
DConcat("Category","Shipping","[TrackingNo]=" & [Shipping].[TrackingNo]) AS ShippingCategory,
Shipping.Mode, Shipping.ActSailDate, Shipping.EstArrivalDate,
Shipping.ActArrivalDate, Shipping.QtyReceived, Shipping.Signature
FROM Projects INNER JOIN (tmpShipping
LEFT JOIN Shipping ON tmpShipping.TrackerNo = Shipping.TrackerNo)
ON Projects.StoreNumber = tmpShipping.StoreNumber
WHERE (DConcat("Category","tmpShipping","[TrackingNo]=" & [tmpShipping].[TrackingNo])
<>DConcat("Category","Shipping","[TrackingNo]=" & [Shipping].[TrackingNo]))
OR (Shipping.Shipment<>[tmpShipping]![Shipment])
OR (Shipping.Mode<>[tmpShipping]![Mode])
OR (Shipping.ActSailDate<>[tmpShipping]![ActSailDate])
OR (Shipping.EstArrivalDate<>[tmpShipping]![EstArrivalDate])
OR (Shipping.ActArrivalDate<>[tmpShipping]![ActArrivalDate])
OR (Shipping.Signature<>[tmpShipping]![Signature])
OR (Shipping.ID Is Null);
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
Can you please post the SQL of tmpQuery2, and also give a description of your tables and how they are related.
--
Graham Mandeno [Access MVP 1996-2013]