This discussion is archived
2 Replies Latest reply: Nov 28, 2012 7:16 AM by CraigB RSS

Disable Button from the same Button Code

961483 Newbie
Currently Being Moderated
Dear Members,

I have a Form which has a Button. Lets Say the Button name "EXECUTE_CO_CUST".

When I press the Button then it does few validations and if all of them are successful then the action completes successfully. I need a way where I can Disable the Button when i press it.(This should only happen when its fails the validations).

In simple terms if I press "EXECUTE_CO_CUST" Button then the Button should be disabled. How can I do that.

I tried using the below code in "WHEN-BUTTON-PRESSED" trigger:
set_item_property('BLOCK.EXECUTE_CO_CUST',ENABLED,PROPERTY_FALSE);
but its giving me the following error:
FRM-41032: Cannot set ENABLED attribute of current item BLOCK.EXECUTE_CO_CUST
Thanks
Sandeep
  • 1. Re: Disable Button from the same Button Code
    MLBrown Journeyer
    Currently Being Moderated
    Try navigating to a different item before you try to disable that one.
    go_item('BLOCK.DIFFERENT_ITEM');
    set_item_property('BLOCK.EXECUTE_CO_CUST',ENABLED,PROPERTY_FALSE);
  • 2. Re: Disable Button from the same Button Code
    CraigB Guru
    Currently Being Moderated
    Another option would be to create a Zero (0) second non-repeating Timer in your When-Button-Pressed trigger. This would ensure your button is only disabled when your specific circumstance existed. Here is a small example of how to use a Timer.
    /* When-Button-Pressed trigger */
    DECLARE
      t_timer   TIMER;
    BEGIN
      IF ( "Your test condictions here " = TRUE ) THEN 
        -- I need to disable the button based on a TRUE condition.
        -- -------------------------------------------------------
        t_time := Create_Timer('DISABLE_BUTTON',1,NO_REPEAT);
      END IF;
    END;
    /* Example Module/Form level When-Timer-Expired trigger */
    DECLARE 
      v_timer   VARCHAR2(30);
    BEGIN
      v_timer := Get_Application_Property(TIMER_NAME);
      
      IF ( v_timer = 'DISABLE_BUTTON' ) THEN 
        /* Notice: the timer name MUST match the declaration (including Case). */
        
        -- Disable the Calling Button.
        -- ---------------------------
        Set_Item_Property('YOUR.BUTTON_NAME',ENABLED,PROPERTY_FALSE);
      END IF;
    END;
    By the way, It is always a good idea to list your Forms version (eg; 10.1.2.02 versus 10g) when asking questions.

    Hope this helps.

    Craig...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points