Question : Show All Records In Query if Nothing Selected in Listbox - Part II

Was this the right way of running the SQL for this for multiple statements (see below)?  The reason I ask is that is looks incredibly goofy in "design view" and gives me an error if I try to save the query while in design view - although no errors while saving in SQL view and it seems to run the query fine:

WHERE ((Not Exists (Select 1 FROM TempDivision) Or [Common System Name] In (Select Division FROM TempDivision)) AND (Not Exists (Select 1 FROM TempAgeRange) Or [AgeRange] In (Select [AgeRange] FROM [TempAgeRange])) AND (Not Exists (Select 1 FROM TempDepartment) Or [Dept Descr] In (Select Department FROM TempDepartment)) AND (Not Exists (Select 1 FROM TempYOSRange) Or [YOSRange] In (Select [YOSRange] FROM [TempYOSRange])) AND (Not Exists (Select 1 FROM TempUnion) Or [Union Code] In (Select [Union] FROM TempUnion)))

Answer : Show All Records In Query if Nothing Selected in Listbox - Part II

Yes, precisely: it's syntactically fine. This isn't the most optimal solution, but that is another matter. Formally, SQL optimises

    (a or b) and (c or d) and (e or f)

just as well as

    (a and b) or (c and d) or (e and f)

but the query design grid really only manages the second structure correctly (as this is the most frequent criteria structure used by average users).

Cheers!
(°v°)
Random Solutions  
 
programming4us programming4us