filter with OR

derez

Expert
Licensed User
Longtime User
The help for Table control says this:

You can add conditions using AND, OR:
Table1.Filter ("colApples = 8 AND colFirstName = 'John'")

I'm using OR to filter the contents of four columns which may contain a keywords, in any of the columns, and I want to get all the lines which contain that keyword.

The keyword is defined in a string "st".

B4X:
If St <> "" Then rcptdb.Filter("Ing1='" & st & "'" OR "Ing2='" & st & "'" OR "Ing3='" & st & "'" OR "Ing4='" & st & "'")




when compiling for desktop or device I get the attached error , running in IDE goes fine without errors.
If I cut the filter sentence to eliminate the other options - it compiles:
rcptdb.Filter("Ing1='" & st & "'" )

I'll appreciate a hint ...:BangHead:
Thanks

Edit: Found it myself , it should be like this, where the OR is part of the condition string:

If St <> "" Then rcptdb.Filter("Ing1='" & st & "' OR Ing2='" & st & "' OR Ing3='" & st & "' OR Ing4='" & st & "'")
 
Last edited:
Top