Query is supposed to pull all the records from that shift. Each work shift begins at 8 am and ends at 8 the next morning. At any time during the shift in which the query runs, it pull all the records from that day and if the current time after midnight, the records yesterday.
After I enabled query design error:
"The SQL statement could not be executed because it contains ambiguous outer joins. To force one of the joins to be performed first, create a separate query that performs the first join and then include that query in your SQL statement."
Here is the SQL of query:
SELECT Deliveries.ReceptionTime, Customers.FullName, [StreetName] & " " & [Deliveries.ApartNumber] & " / " & [Deliveries.HouseNumber] & [Deliveries.EntryNumber] & ", " & IIf([Deliveries.IsUnit]=True,"unit, ","") & [CityName] AS Address, Deliveries.PayByCreditCard, Deliveries.IsPrepaid, Deliveries.TotalPrice, Deliveries.Comments
FROM Cities LEFT JOIN ((Customers LEFT JOIN Deliveries ON Customers.[CustomerID] = Deliveries.[CustomerID]) INNER JOIN Streets ON Deliveries.StreetID = Streets.StreetID) ON Cities.CityID = Streets.CityID
WHERE (((Deliveries.ReceptionTime)="Date()") AND ((DatePart([h],Now()))>8) AND ((DatePart([h],[ReceptionTime]))>8)) OR (((Deliveries.ReceptionTime)="Date()") AND ((DatePart([h],Now()))<8) AND ((DatePart([h],[ReceptionTime]))<8)) OR (((Deliveries.ReceptionTime)=DateAdd("d",-1,Date())) AND ((DatePart([h],Now()))<8) AND ((DatePart([h],[ReceptionTime]))>8));
Here is Printscreen of the query:
BIG THANKS GUYS!!!![]()