devxlogo

Problem with Filter function and char()

Problem with Filter function and char()

Question:
I want to filter out data from a datawindow during runtime. I have a sle-field in which the user enters a search string (for example, “SM”). This should be used to filter one column in the datawindow, in this case the Name-column. Since the user entered “SM,” the program should list:

 "SMITH JOHNSON" "SMITH BERG""SMILEY"

and so on–all names beginning with “SM.”I tried to use following SetFilter string:

dw_search.SetFilter("left(name, '"+char(ll_Filter_Length)+"') = '"+ sle_search.Text+"'")

But that doesn’t work. If I change '"+char(ll_Filter_Length)+"' to 3 or another digit, it works, but since I want the search function to be flexible (that is, the user can enter different long search words), this isn’t any good.

Answer:
You need to use the String function instead of the char function.

devx-admin

Share the Post: