Is there something obviously wrong with this where clause?
Code:
WHERE
rt_BEHI_BHBH.Index = (
CASE
WHEN qry_BEHI_values.BHBHValue < (SELECT MIN(Value) FROM rt_BEHI_BHBH) THEN 1
WHEN qry_BEHI_values.BHBHValue > (SELECT MAX(Value) FROM rt_BEHI_BHBH) THEN 10
ELSE (SELECT Index FROM rt_BEHI_BHBH WHERE Value = qry_BEHI_values.BHBHValue)
END )
I've been staring at this for a while, and I can't get it right. Access just gives a generic syntax error (missing operator) for the case statement.