I saw many people asking question on forums that how to set focus on text item in Oracle Forms, so I thought I should give an example for it. Actually it is very simple thing in Oracle forms to set focus on text item or any navigable item in Forms.
I will tell you in this post to how to set focus on text item in Oracle Forms. Below is the example have a look.
For example you have a database data block named EMP and there is a text item TXT_ENAME in which you want to set focus and you have a text item TXT_DEPTNO field in DEPT database data block. You requirement is to set focus to text item TXT_ENAME in EMP block after user inputs a value in TXT_DEPTNO in DEPT block and press enter. In this case you can write a trigger KEY-NEXT-ITEM on TXT_DEPTNO field in DEPT database data block to set focus to text item TXT_ENAME.
Block 1: DEPT
Text Item 1: TXT_DEPTNO
Block 2: EMP
Text Item 2: TXT_ENAME
Write the below code in trigger KEY-NEXT-ITEM on TXT_DEPTNO text item:
Begin go_item('EMP.TXT_ENAME'); End;
In above example we are simply addressing the item TXT_ENAME in data block EMP. So if any text item you want to set focus just mention BLOCK.TEXT_ITEM name in single quotes in go_item() procedure to set focus on text item in Oracle Forms. And not only text items, you can set focus to any navigable item in form.
Go_item() is a restricted procedure and below are the details:
1. In Enter Query mode, GO_ITEM cannot be used to navigate to an item in a different block.
2. You cannot use GO_ITEM to navigate to a non-navigable item, such as display item.