View Single Post
  #3  
Old December 8th, 2009, 05:31 PM posted to microsoft.public.access.queries
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Boolean expressions in the where statement

I replied to this in one of your earlier threads:

http://www.accessmonster.com/Uwe/For...405459301aeuwe


Translating what I said then to your current example:

SELECT *
FROM [Table]
WHERE ([chkA] = Forms![YourForm]![chkA]
OR Forms![YourForm]![chkA] = FALSE)
AND ([chkB] = Forms![YourForm]![chkB]
OR Forms![YourForm]![chkB] = FALSE);

The logic behind this was explained in the other thread. Note the point I
made there about the possibility of the unbound check boxes being Null when
the form opens.

Ken Sheridan
Stafford, England

Paul Washburn wrote:
Im trying to build a form with multiple check boxes that each apply a filter
to the records displayed. I need for the user to be able to select any
combination of the checkboxes and have the resulting records filtered
accordingly.

I was thinking something along the lines of a "select" or statement or an
if...else loop, but unfortunately im fairly new with sql am having trouble
with the syntax, assuming its even possible.

Something along the linse of:

Select * from Table Where
If (chkA = true) then chkA
Else (chkB = true) then chkB
else (chkA = true) and (chkB = true) then chkA and chkB
else *;

Any help would be greatly appreciated.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200912/1