In the ClassDeclaration method of the form, define a range.
QueryBuildRange CurrencyQBREUR;
QueryBuildRange CurrencyQBRUSD;
Step 2: Instantiate the new range.
In the init() method on the datasource of the form, you assign the range to a specific field (after the super call).
public void init()
{
super();
CurrencyQBREUR = this.query().dataSourceName(‘Currency’).addRange(fieldnum(Currency, CurrencyCode));
}
public void init()
{
super();
CurrencyQBRUSD = this.query().dataSourceName(‘Currency’).addRange(fieldnum(Currency, CurrencyCode));
}
Step 3: In the last step, you assign a value to the range.
This is done in the executeQuery method on the same datasource of the form. Before the super call. Like this:
DataSource: CurrencyEURpublic void executeQuery()
{ ;
CurrencyQBREUR.value(queryvalue(‘EUR’));
super();
}
{ ;
CurrencyQBRUSD.value(queryvalue(‘USD’));
super();
}
this.query().dataSourceName(‘Currency’).addRange(fieldnum(‘Currency’,CurrencyCode)).value(queryvalue(‘USD’));
But this way, it’s fixed. If you choose the 3 step method, you could for example use a variable in the range value. The way to go would be to place an input field on your form. Get the value from it and supply it in the executeQuery() method.
{ ;
CurrencyQBRUSD.value(queryvalue(MyInputField.text()));
super();
}
Just make sure the executeQuery method is executed, thus applying the desired filter (maybe be using a button on your form to activate it).