0

I have a BindingSource filter with multiple conditions. The reason for that is so I could have a single search_textbox to find a specific record...

I have one problem though, I have a slightly more permanent condition"Status LIKE '{0}' AND...", but once I type anything, that restriction is ignored. I assumed the 'AND' would take care of that, but apparently I was mistaken.

bs.Filter = String.Format("Status LIKE '*{0}*' AND Customer_Code LIKE '*{1}*' OR Customer_Name LIKE '*{1}*' OR Customer_JobNumber LIKE '*{1}*' OR Customer_Date LIKE '*{1}*' OR Order_Number LIKE '*{1}*'", select, textBox1.Text);

Any advice? Thanks Kindly

Herman Vercuiel

EDIT:

Sorry, probably should have mentioned this is recurring inside a TextChanged Event..

Herman Vercuiel
  • 69
  • 2
  • 13

1 Answers1

1

Don't you need to add a couple of parenthesys around your conditions?

bs.Filter = String.Format("Status LIKE '*{0}*' AND ( Customer_Code LIKE '*{1}*' " + 
                          "OR Customer_Name LIKE '*{1}*' OR Customer_JobNumber LIKE '*{1}*' " + 
                          "OR Customer_Date LIKE '*{1}*' OR Order_Number LIKE '*{1}*')", 
                          select, textBox1.Text);

To mean STATUS LIKE '*<select>* AND (one or more the following condition is true)

Steve
  • 213,761
  • 22
  • 232
  • 286