validation and cursor navigate?

hi

i need to validate all items on my form .... if there is any error on a specific item

 the cursor(mouse or key) will go to it and let user 2 correct it..........is that possible?

i don't  want to use post_text_item trigger

thanks
julia2004Asked:
Who is Participating?
 
musduConnect With a Mentor Commented:
Hi,

add this line to the beginning of your when-button-pressed trigger;

-This line causes the when-validate-item trigger to be fired during Validate(FORM_SCOPE);
:BLOCK1.Item3 := :BLOCK1.Item3;

-- your code
Validate(form_scope);

IF NOT Form_Success THEN
   
   -- Instead of hard-coding of your item name you can assign item name to a variable in when-validate-item triggers
   Go_Item('block1.item3');

END IF;  
0
 
mudumbeCommented:
You can use VALIDATE built-in.
0
 
musduCommented:
Hi,

to validate the all fields in a form you can use VALIDATE(FORM_SCOPE) built-in.

Your fields should have when-validate-item triggers and in it you should use RAISE FORM_TRIGGER_FAILURE statement to fail validation. VALIDATE(FOTM_SCOPA) built-in executes all when-validate-item-triggers (also checks validation properties of items). If a validation fails, cursor is placed on the item automatically.

regards
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
julia2004Author Commented:

thansk

i did it befor ... i use the validation builtin and and set the scope to form

and i put (post_text_item) triggers to all fields i need to check it..

it is not working

i change the items validation triggers to (when validate item) ...also it is the same result

it  skip the validation and do commit!!




 
0
 
mudumbeCommented:
It is recommended that you validate in WHEN-VALIDATE-ITEM trigger.

Check if validation is turned off....If so forms will not do validation.

This has to be done programatically using SET_FORM_PROPERTY built-in:

The following will turn off validation:

SET_FORM_PROPERTY('form_name', VALIDATION, PROPERTY_FALSE);

To find whether it is turned off use:

SET_FORM_PROPERTY('form_name', VALIDATION);
0
 
julia2004Author Commented:

it is the same problem :(

get_form_property('myform',valdiation) = true

i think the problem is on the place of calling validate ?

what is your recommendation?


thanks again
0
 
musduCommented:
Hi,

set "Validation Unit" property of your form to "DEFAULT", create a when-validate-item trigger for one of your items and use RAISE FORM_TRIGGER_FAILURE statement to fail validation. Add some messages in your trigger code in order to understand whether or not it is fired.

copy and paste your trigger code please.

regards.
0
 
julia2004Author Commented:

i put save button on my form fire this trigger when-button-pressed
(       Validate(form_scope);
IF NOT Form_Success THEN
          RAISE Form_Trigger_Failure;
         END IF;  
  IF :System.Form_Status = 'CHANGED' THEN
 
           Commit_Form;    
     IF :System.Form_Status <> 'QUERY' THEN  
         Bell;       RAISE Form_Trigger_Failure;  
   END IF;
     END IF; )

on  item3 (it is a summation of item1 and item2 )
 i put the trigger when_validate_item
( IF  :Block1.Item3 <> (:Block1.Item1 +:Block1.Item2) THEN
    Message(' Please Check  The Summation ');
    RAISE Form_Trigger_Failure;
      END IF; )




0
 
julia2004Author Commented:

thanks for your help

it is still not working


your solution check only the result ... item1 and item2 not effected
it will be pass them without checking...

for example
at runtime
i put  item1 = 1 and item2 = 2 and  left  item3 = null
it will be accept it and also
if i put
     item1 = null  and item2 = 2 and    item3 = 3

--
it is useless way to check all item one by one ( i have more than 50 different item on my form need to recalculate ).

i think my problem is clear now
0
 
musduCommented:
Hi,

how do you populate your items? If your item is changed above code will fire validation triggers. If your items are not changed, validate built-in will not fire them. That's why I assigned BLOCK1.Item3 to itself.

Is it acceptable to put all validation triggers into your button code?
0
 
julia2004Author Commented:

yes.. it will fire validation trigger only at item3....
if i leave it with out change and change item2 or item1 ... it will be accept it

i don't want to validate all items


----
 it is database items
0
 
musduCommented:
If your item is changed, you need nothing to validate it. When-validate-item trigger is automatically fired when the cursor leaves the item.

Could you copy-paste one of your when-validate-item trigger please?
0
 
julia2004Author Commented:

i wrote it befor

on  item3 (it is a summation of item1 and item2 )
 i put the trigger when_validate_item
( IF  :Block1.Item3 <> (:Block1.Item1 +:Block1.Item2) THEN
    Message(' Please Check  The Summation ');
    RAISE Form_Trigger_Failure;
      END IF; )

0
 
musduCommented:
Hi,

write below code in when-button-pressed-trigger. (Change BLOCK2 with your block name) Your button must be in a different block. (If it's in the same block we should make some changes in this code)

DECLARE

  vItem VARCHAR2(100);
  vFirstItem VARCHAR2(100);
  vLastItem VARCHAR2(100);
  vMyBlock VARCHAr2(30) := 'BLOCK2';

BEGIN
      
      vFirstItem := Get_Block_Property(vMyBlock, FIRST_ITEM);
      vLastItem := Get_Block_Property(vMyBlock, LAST_ITEM);
      vItem := vFirstItem;
      
  LOOP
 
    Copy(name_in(vItem), vItem);
    EXIT WHEN vLastItem = vItem;      
    vItem := Get_Item_Property(vItem, NEXTITEM);
 
  END LOOP;

  validate(form_scope);  

END;

0
 
julia2004Author Commented:

hi musdu

i solve it .... the problem was in null values

i used NVL function ...and it is working


 IF  NVL(:Block1.Item3,0) <> (NVL(:Block1.Item1,0) +NVL(:Block1.Item2,0)) THEN
    Message(' Please Check  The Summation ');
    RAISE Form_Trigger_Failure;
      END IF; )

thanks alottt for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.