Question

I am writing a program that hooks into an Access Database. I have 3 search criteria I am attempting to combine. Two of the filters are derived from checkboxes, while the 3rd is a searchbox. Individually these 3 work great. However, when attempting to Concatenate the filters it seems to only recognize the 'CheckedSListFilter'. I have tested multiple iterations of the concatenated string without any luck. I'm hoping this is just a syntax issue. Thanks for your help.

        string SFilter = CheckedSListFilter();// method returns string "S = 'w1' OR S = 'w2' OR S = 'w3'"
        string PFilter = CheckedPStatusFilter();//method returns string "PA = 'True' OR "PB = 'True'"
        string CFilter = comboBox_SearchFields.Text;
        string filter = CFilter + " LIKE '" + "*" + textBox_search.Text + "*" + "'";//returns "R LIKE '*g*'"

                BindingSource bs = this.projectBindingSource;
                bs.Filter =  filter+" AND "+"("+PFilter +" OR "+SFilter+")";
Was it helpful?

Solution

Solved this on my own. Order of operations was tripping me up. Ended up doing something like this: bs.Filter = "("+SFilter+")"+" AND "+"("+PFilter+")"+" AND "+"("+PFilter+")"; All now works as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top