View Full Version : Checkbox Filter Query


wtrimble
01-19-2010, 05:38 AM
Hello all,

I have a form with a Subform Query on it. The query right now can be filtered by two Combo Boxes on the form. I need to, however, add 12 Check Boxes to also filter the query and I'm not sure the best way to do this because multiple check boxes need to be checked at one time. All my filtering is done in Query design and not in VB. Here is my SQL I have right now:


SELECT *
FROM tblProjectInfo
WHERE (((MonthName(Month([StartDate])))=[forms].[rptprojectyear].[combo2]) AND ((Year([StartDate]))=[forms].[rptprojectyear].[combo0])) OR (((Year([StartDate]))=[forms].[rptprojectyear].[combo0]) AND (([forms].[rptprojectyear].[combo2]) Is Null)) OR (((MonthName(Month([StartDate])))=[forms].[rptprojectyear].[combo2]) AND (([forms].[rptprojectyear].[combo0]) Is Null)) OR ((([forms].[rptprojectyear].[combo2]) Is Null) AND (([forms].[rptprojectyear].[combo0]) Is Null));


where form "rptprojectYear" is the form with the subform Query. It basically states filter by "Combo0" or don't if "Combo0" is null and filter by "Combo2" or don't if "Combo2" is null. (I'm filtering by Year and Month)

I have a field "Project_Scope" with values like: LPA, NH3, REG, AIG... where I need to filter with checkboxes.

Any suggestions on how to add this extra filter, saying maybe in VB something like: if me.checkboxLPA = true, then SQL = (current)SQL + Where "Project_Scope = "LPA" ??

Thanks for any advice

GalaxiomAtHome
01-19-2010, 05:53 AM
Your check boxes are boolean so you just refer to them as the True value.
WHERE whatever AND Forms!checkboxname

This is the same as:
WHERE whatever AND Forms!checkboxname = True

wtrimble
01-19-2010, 05:58 AM
Ah, ok. Is there a way in VB to refer to a current SQL and then add a where filter to it??