Date criteria in a query

Humpty

New member
Local time
Today, 17:13
Joined
May 21, 2004
Messages
7
Wonder if anyone can help with the syntax in this query? It always returns no results and I can't for the life of me understand why.

Code:
SELECT tblExpectedShipments.ShipmentDate
FROM tblExpectedShipments
WHERE (((tblExpectedShipments.ShipmentDate)=IIf([Forms]![frmSelectShipperReport]![chkOverdue]=0,(tblExpectedShipments.ShipmentDate)>Date(),(tblExpectedShipments.ShipmentDate)<Date())));

Any pointers would be greatly appreciated. Thanks.
 
not entirely sure, but perhaps
Code:
SELECT tblExpectedShipments.ShipmentDate
FROM tblExpectedShipments
WHERE (((tblExpectedShipments.ShipmentDate)=#IIf([Forms]![frmSelectShipperReport]![chkOverdue]=0,(tblExpectedShipments.ShipmentDate)>Date(),(tblExpectedShipments.ShipmentDate)<Date())#));

Basically wrapping the result of the Iif with ## so that it is forced to be seen as a date value.
 
Thanks workmad. It looked like it could be a possible solution but afraid it just returns the error "The expression you entered has and invalid date value". Any other thoughts?
 
Hmm... of course it wouldn't. Should really check queries before changing them :D

tblExpectedShipments.ShipmentDate>Date() is a true/false boolean expression.

if you are comparing this to a date, then no you wouldn't ever get any results ;)
 

Users who are viewing this thread

Back
Top Bottom