In the case you have multiple fields in a table that can be combined into one phrase and you want to perform a query on the phrase using a user input, the code below can be utilized in a search bar object method.
An example of this situation is if the table contains something like a first name field and a last name field. You want to search by first name the (first field) while also being able to specify the last name (secodnd field).
The code below uses Split string to split the user's input into multiple strings and it is set to split into a new string each time the user types a space. The strings are added into a collection referenced to as $col. The first string in the collection (first word the user types) is used to query the first field. The second string in the collection (second word the user types) is used to query the selection on the second field.
C_TEXT($input) $col:=New collection $input:=Get edited text Case of : (Form Event=On After Edit) If ($input#"") $col:=Split string($input;" ") QUERY([People];[People]first_name=$col[0]+"@") If ($input%" ") If ($col[1]#"") QUERY SELECTION([People];[People]last_name=$col[1]+"@") End If End If End If End Case |