create sql view lv_Myview as select ... ; from CurrentTable where somefield = ?cSomeValue ; order by somefieldWhen a record from the another table is selected:
if not used('lv_MyView') use lv_MyView in 0 nodata endif local cSomeValue cSomeValue = upper(alltrim(AnotherTable.FieldX)) *!* assumes you have an index on upper(SomeField) for optimization requery('lv_MyView') ThisForm.GridName.Refresh()