0
votes

I created a textbox and a button. What I wanted to happen is that after pressing the button and the textbox is null, the focus must go back on textbox.

BEGIN       
   IF :blk.textbox IS NULL THEN
        msg_alert('Error message', 'E', FALSE);
   end if;    
END; 

I'd already tried to put the code above in WHEN-BUTTON-PRESSED trigger but nothing happens.

2

2 Answers

3
votes

Put your code in WHEN-VALIDATE-ITEM trigger of :BLK.TEXTBOX item.

BEGIN       
    IF :blk.textbox IS NULL THEN
        msg_alert('Error message', 'E', FALSE);

        --if msg_alert procedure has no RAISE FORM_TRIGGER_FAILURE, then uncomment next line
        -- RAISE FORM_TRIGGER_FAILURE;
   end if;    

END; 

You can also set the MOUSE NAVIGATE property to FALSE (or NO) of the button so that the focus won't go to that button after it was clicked.

use GO_ITEM also to set the focus to the textitem. sample,

GO_ITEM('blk.textbox');
1
votes

Why reinventing the wheel? Set text item's REQUIRED property to YES.

After reading comments you left for @eifla001's answer, I'm not sure what is the code you have. Something like this works properly on my Forms 10g (but should work on any version):

-- WHEN-BUTTON-PRESSED trigger 
if :blk.textbox is null then
   go_item('blk.textbox');
end if;

If it doesn't work, check TEXTBOX's properties. Is it really a text (or a display) item? Is it enabled? Are there any SET_ITEM_PROPERTY calls that make it unavailable?

Because, task you're about to perform is really trivial, that should work just like that.