Another table filter question

Discussion in 'Questions (Windows Mobile)' started by michaelm, Aug 23, 2009.

  1. michaelm

    michaelm Member Licensed User

    How do I filter for a word that is typed into a textbox?
  2. Ariel_Z

    Ariel_Z Active Member Licensed User

    Suppose the textbox is called TextBox1, then you can try:

    table1.filter = "[col_name] = " & TextBox1.Text
    Let me know if this helps you. Note that [col_name] is the name of the relevant column, which you want to filter.
  3. michaelm

    michaelm Member Licensed User

    It's not working. I get a syntax error that says: 'Missing operand after '=' operator' Do you have any other ideas?:confused:
  4. michaelm

    michaelm Member Licensed User

    I've played around with it and it seems to work when I enter the name of the column in the textbox, of course it returns all rows in the column. I need to filter for only certain entries within the column that meet the search criteria. Any ideas on what I am doing wrong?
  5. Ariel_Z

    Ariel_Z Active Member Licensed User

    Sorry. Forgot the brackets.

    table1.Filter = "col1 = '" & textbox1.Text & "'"
    Note the first bracket. The column is assumed to be called col1.
    Let me know how it goes.
  6. michaelm

    michaelm Member Licensed User

    Works great. Thank you!

    Now how do I put some wildcards in it so that it will find anything with only a partial description. For example: If i wanted to find all rows with the word "apple" but that word could be at the beginning, middle or end of the text.

    Please advise.
  7. Ariel_Z

    Ariel_Z Active Member Licensed User

    Replace the " = " signe (equals) with the work " Like ".
    Then write in the textbox something like "app*"

    Note - remove the brackets from all the above.

    The idea is that you must enclose the value itselft in brackets as I demonstrated. The = sign indicates equation (identity). The Like operator indicates the quite wide range of similarities including wildcards.

    The filter string is written like a WHERE clause in a SQL statement (eg. ColumnName = Value AND ColumnName2 = Value2).

    To make it easier for users, you may want to create a filter builder. You might have a ComboBox loaded with column names, another loaded with operators (=, >, <, <>, etc) and a TextBox for the value. The user selects a column, and operator, and types a value. They click an Add button and you build a filter string.

    Let me know how it works...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice