hmmm ok then, guess I need to figure out if I need a screwdriver or a sledgehammer
So please help me understand the following sql:
SELECT [Address] & ", " & [City] & ", " & [State] & " " & [Zip] AS FullAddress, PCID, PMID, ServiceType, DateCompleted, pInvoice, nInvoice, ConvInvoice AS dInvoice, "Project" AS Type
FROM Customers INNER JOIN Projects ON Customers.CustomerID = Projects.CustomerID
WHERE (((Projects.PCID) Like IIf(IsNull([TempVars]![tmpPCID]),"*",[TempVars]![tmpPCID])) AND ((Projects.PMID) Like IIf(IsNull([TempVars]![tmpPMID]),"*",[TempVars]![tmpPMID])) AND ((Projects.DateCompleted) Between [TempVars]![tmpstartdate] And [TempVars]![tmpenddate]))
UNION SELECT [Address] & ", " & [City] & ", " & [State] & " " & [Zip] AS FullAddress, PCID, PMID, ServiceType, DateCompleted, pInvoice, nInvoice, ConvInvoice AS dInvoice, "ChangeOrder" AS Type
FROM Customers INNER JOIN ChangeOrders ON Customers.CustomerID = ChangeOrders.CustomerID
WHERE (((ChangeOrders.PCID) Like IIf(IsNull([TempVars]![tmpPCID]),"*",[TempVars]![tmpPCID])) AND ((ChangeOrders.PMID) Like IIf(IsNull([TempVars]![tmpPMID]),"*",[TempVars]![tmpPMID])) AND ((ChangeOrders.DateCompleted) Between [TempVars]![tmpstartdate] And [TempVars]![tmpenddate]));
First select query - table Customers inner join on table Projects, results are records showing the selected fields for the given date range and matching to the current variables for PCID and PMID (if assigned)
Second select query - table Customers inner join on table ChangeOrders, results are records showing the selected fields for the given date range and matching to the current variables for PCID and PMID (if assigned)
SOOO this would be used to show records that are in tables Customers, Projects, and ChangeOrders that have the same CustomerID, and have a completion date that falls with the date range being searched correct? So I would think, since this union query is titled JobsCompleted, this is used to run reports showing completed jobs. I don't see why you couldn't just use a selection query to select records that only have a completion date, unless it has to do with the PCID and PMID variables? Or am I just totally wrong?