6. Working with Arrays, Table Fields, and Collections : Table Field Operations : How You Can Scroll to a Specific Row : How You Can Use the SetInputFocus Method to Scroll
 
Share this page                  
How You Can Use the SetInputFocus Method to Scroll
You can use the SetInputFocus method to set the input focus of a frame to a specific cell of a table field. Its syntax is:
integer = tablefield.SetInputFocus([row=integer], [column=varchar(256)])
row
Identifies the row in the array to which to move the input focus
Default: row 1
column
Identifies the name of the column in the table field to which to move the input focus
Default: the first displayed column
The SetInputFocus method returns ER_OK (value of 0) if the parameters are valid, and it returns a nonzero number if there is an error.
When you use the SetInputFocus method, the change in focus occurs at the end of the current event block. The method triggers any appropriate Exit, SetValue, and Entry events. For example, the following event block accepts a number as input from the user and then scrolls the table field display to that row:
declare
  resp = varchar(80);

...
on click menu_button.ChangeRow =
begin
  resp = prompt 'Enter the number of the row '+
    'you want to see.';
  status = field(custtable).SetInputFocus(row =
      int4(resp));
  ...
end;
When you use the SetInputFocus method to specify a column, the column name must be quoted or contained in a varchar variable.