Problem

You have a linked table (say "category") with at least two fields: "id" and "description". You want to rapidly select the right category typing few letters of description rather than select the row from a long list.


Solution

Link as usual che table "category" using a field say "idCategory", add a computed field for the description ("Description") with an expression formula: idCategory.description.
In this new field properties under "Rapid Selection - Column" put the name of the foreign key field (in this example "idCategory") and under "Rapid Selection - Condition" put the filter expression which shoud return a boolean. A valid condition formula is: valueLike(Description,'*'+?+'*'), where "Description" is the computed field where you will begin typing, after pressed Enter if only a row match the field will be populated with the selected one, if more than one match you will be presented with a list of all matching rows.

What if there is no match? An error is raised but you coul manage to insert the new value as well. Just define in "category" table the default form and add the following code to the form:
public addNew(){
dataBar1.addNew();
}

public edit(uid){
dataBar1.moveTo(uid);
}

public moveTo(uid){
dataBar1.moveTo(uid);
}

public getUID(){
return dataBar1.getUID();
}

Just be sure that the DataBar in the form is named dataBar1 or change the name accordingly. This way you will be able to create new rows or edit existing ones. Just a tip, to see all possible values type an asterisk "*" and press enter and you'll be prompted with a list of all possible values where you could delete, modify, create all the values.

Published in Wed, 12 October 2011 10:53