This discussion is archived
3 Replies Latest reply: Jan 24, 2012 1:53 AM by 789736 RSS

enabling and disabling a button

789736 Explorer
Currently Being Moderated
Guys, wondering if you could help me out here. I have a multi record block of 10 records, I also have a button which I only want to enable if the user navigates to a record where a certain column = 'Y' so as the user moves up and down through the records the button wil enable and disable accordingly. I was simply wondering if this is possible and if so how would I go about doing this. What specific trigger should I be looking at.

Thanks for any help I may recieve.
  • 1. Re: enabling and disabling a button
    HamidHelal Guru
    Currently Being Moderated
    786733 wrote:
    Guys, wondering if you could help me out here. I have a multi record block of 10 records, I also have a button which I only want to enable if the user navigates to a record where a certain column = 'Y' so as the user moves up and down through the records the button wil enable and disable accordingly. I was simply wondering if this is possible and if so how would I go about doing this. What specific trigger should I be looking at.
    If it is simply enable and disable option and not row specific then you can use When-New-Record-Instance trigger at block level.
    and write the following code:
    If :comm='Y' then
     set_item_property('btn',enabled,property_true);
    else
     set_item_property('btn',enabled,property_false);
    end if;
    Hope this will help you.
  • 2. Re: enabling and disabling a button
    CraigB Guru
    Currently Being Moderated
    What is your Forms version? The following code snipet only works with Forms 9i or higher.
    BEGIN
       IF ( :certain_column != 'Y' ) THEN
          Set_Custom_Property('YOUR_BLOCK.ITEM_NAME',:SYSTEM.TRIGGER_RECORD, 'ENABLED', FALSE);
       END IF;
    END;
    as the user moves up and down through the records the button wil enable and disable accordingly.
    If the value of CERTAIN_COLUMN does not change, I would put the code in the Post-Query trigger. Then you are not enable/disabling the button during navigation. The button would simply be disabled for rows where CERTAIN_COLUMN != 'Y'.

    Hope this helps,
    Craig B-)

    If someone's response is helpful or correct, please mark it accordingly.

    Edited by: CraigB on Jan 16, 2013 2:05 PM

    Keep in mind that setting the ENABLED property with the Set_Custom_Item_Property() built-in sets the physical item container not each unique item/value. Consequently, the best option is to mimic the ENABLED/DISABLED properties using a Forms Program Unit (procedure). For example:
    /* This procedure assumes you have a VISUAL_ATTRIBUTE                 */
    /* created called 'ENABLED' and 'DISABLED'.  In my example,           */
    /* I created the DISABLED visual attribute with following properties: */
    /*  Foreground Color = DarkGray                                       */
    /*  Background Color = gray12                                         */
    /* The ENABLED visual attribute does not specify any properties so it */
    /* sets the above properties back to <Unspecified>                    */
    PROCEDURE enable_item (inItem VARCHAR2, inRecord NUMBER, inEnabled BOOLEAN )IS
         paramCount     NUMBER := 0;
    BEGIN
         IF ( inEnabled ) THEN
              Set_Item_Instance_Property(inItem, inRecord, INSERT_ALLOWED, PROPERTY_TRUE);
              Set_Item_Instance_Property(inItem, inRecord, UPDATE_ALLOWED, PROPERTY_TRUE);
              Set_Item_Instance_Property(inItem, inRecord, NAVIGABLE, PROPERTY_TRUE);
              Set_Item_Instance_Property(inItem, inRecord, VISUAL_ATTRIBUTE, 'ENABLED');
         ELSE
               Set_Item_Instance_Property(inItem, inRecord, INSERT_ALLOWED, PROPERTY_FALSE);
              Set_Item_Instance_Property(inItem, inRecord, UPDATE_ALLOWED, PROPERTY_FALSE);
              Set_Item_Instance_Property(inItem, inRecord, NAVIGABLE, PROPERTY_FALSE);
              Set_Item_Instance_Property(inItem, inRecord, VISUAL_ATTRIBUTE, 'DISABLED');
      END IF;
    END enable_item;
    Now call the Enable_Item procedure in your trigger as follows:
    BEGIN
       IF ( :certain_column != 'Y' ) THEN
          Enable_Item('YOUR_BLOCK.ITEM_NAME',:SYSTEM.TRIGGER_RECORD, FALSE);
       END IF;
    END;
    Craig...
  • 3. Re: enabling and disabling a button
    789736 Explorer
    Currently Being Moderated
    Great help. Thanks for your help guys!

Legend

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