here is the sql:
SELECT qryInspectionLastx.[Customer Number], qryInspectionLastx.MaxOfDate,
tblContrAssign.ContractorID, tblContrAssign.ProposalID,
tblContrAssign.DateCntrStart, tblContrAssign.DateCntrStop,
qryInspectionLastx.PriceStart, DateDiff("d",[Maxofdate],Date()) AS Diff
FROM qryInspectionLastx LEFT JOIN tblContrAssign ON
qryInspectionLastx.[Customer Number] = tblContrAssign.ProposalID
WHERE (((tblContrAssign.DateCntrStart)=[pricestart]) AND
((tblContrAssign.DateCntrStop) Is Null Or
(tblContrAssign.DateCntrStop)>[maxofdate])) OR
(((tblContrAssign.DateCntrStart)<[maxofdate] Or
(tblContrAssign.DateCntrStart)=[maxofdate]) AND
((tblContrAssign.DateCntrStop) Is Null Or
(tblContrAssign.DateCntrStop)>[maxofdate])) OR
(((tblContrAssign.DateCntrStart)=[maxofdate]) AND
((tblContrAssign.DateCntrStop) Is Null Or
(tblContrAssign.DateCntrStop)>[maxofdate]))
GROUP BY qryInspectionLastx.[Customer Number], qryInspectionLastx.MaxOfDate,
tblContrAssign.ContractorID, tblContrAssign.ProposalID,
tblContrAssign.DateCntrStart, tblContrAssign.DateCntrStop,
qryInspectionLastx.PriceStart, DateDiff("d",[Maxofdate],Date())
HAVING (((qryInspectionLastx.PriceStart)>[maxofdate] Or
(qryInspectionLastx.PriceStart)<[maxofdate] Or
(qryInspectionLastx.PriceStart)=[maxofdate]) AND
((DateDiff("d",[Maxofdate],Date()))=[# days limited to:])) OR
(((DateDiff("d",[Maxofdate],Date()))=[# days limited to:])) OR
(((DateDiff("d",[Maxofdate],Date()))=[# days limited to:]));
John Vinson said:
John- I tried your suggestion but the query is still returning all records.
With the DateDiff function the number of days being returned looks like an
interger, but the criteria is not being recognized. I am still having the
same problem. If I hard wire the criteria in, it works. I played around
with the query parameter but it didn't like the date data type i specified
for the [# days limited to:] criteria.
Please post the SQL view of the query.
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps