dianemarie
Instructor
Hello, my report allows the user to choose whether or not they want to show canceled orders on the report via a parameter @CNX (Prompt: Show Canceled Orders?). The database field oh.cnx is a char(1) field. If it is blank, the order is not canceled. If it has a letter character (we have almost a full alphabet of possibilities, A-Z) it is a canceled order. After some help from my good friends at Tek-Tips and trial and error, I have gotten this to work with the WHERE query statement shown below (currently with only the first 3 letters). Before I write this out with all the letters, is there a way to simplify it? Also, if I don't add the very last *else ' '* then it doesn't work and I'm not sure why (got that part from a Tek-Tips contributor). Thank you for any help. Diane
WHERE
(CASE @CNX
WHEN 'Y' THEN
CASE oh.cnx
WHEN 'A' THEN 1
WHEN 'B' THEN 1
WHEN 'C' THEN 1
WHEN '' THEN 1
ELSE 0
END
WHEN 'N' THEN
CASE oh.cnx
WHEN 'A' THEN 0
WHEN 'B' THEN 0
WHEN 'C' THEN 0
WHEN '' THEN 1
ELSE 0
end
else ' '
END) = 1
WHERE
(CASE @CNX
WHEN 'Y' THEN
CASE oh.cnx
WHEN 'A' THEN 1
WHEN 'B' THEN 1
WHEN 'C' THEN 1
WHEN '' THEN 1
ELSE 0
END
WHEN 'N' THEN
CASE oh.cnx
WHEN 'A' THEN 0
WHEN 'B' THEN 0
WHEN 'C' THEN 0
WHEN '' THEN 1
ELSE 0
end
else ' '
END) = 1