Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which Forms (v5) Trigger should I use????

Status
Not open for further replies.

jeannie322

Programmer
May 18, 2001
25
US
I am using Forms 5.

I have a field (FSC) with a LOV attached. There are essentially 2 values in the lov,
0 = no MSDS
1-7000 = various descriptions for the MSDS(material Safety Data Sheets)

if they choose 1-7000 it populates the field (DESCR) with the description of the MSDS they chose and then disables it so they cant put in any garbage.
But if they chose 0 from the LOV in the field (FSC) then it enables the field (DESCR) and they can input whatever they want for the item description.

The problem I have is I am not sure which trigger I need to use to accomplish my goal. I have put a WHEN-VALIDATE-ITEM trigger on the FSC field with the following code

if :pr_items.fsc = 0
then
set_item_property('pr_items.descr',enabled,property_TRUE);
elseif
:pr_items.fsc is NULL then
set_item_property('pr_items.descr',enabled,property_TRUE);
else
:pr_items.descr := :pr_items.msds_desc;
--populates the descr field with the MSDS description
set_item_property('pr_items.descr',enabled,property_false);
--disables the DESCR field
end if;

I can create a record with no problem. Then when I try and update the record it
will not ENABLE the property on the DESCR field when I choose a 0 value for the FSC field. But I can change it to any value between 1-7000 and it will populate the DESCR field and disable the DESCR as well (that is what I want it to do).
Also, The initial value of the DESCR field is set to YES (TRUE).

Can anyone suggest a trigger to use when updating the record to allow the DESCR field to accept update when I chose a value of 0 for the FSC field. It just gives me the
error FRM-40200: FIELD IS PROTECTED AGAINST UPDATE. -referring to the
DESCR field.

If you need any further info, please let me know..

Thanks in advance!!!!!!!!
 
When you set item property enabled to false, you can't just set it back to true, you have to fix the updatable and some others. If you look under the set_item_property built-in in the help file it has a propa gated changes section at the bottom!
 
I didnt see what you were talking about (in the help file).
So, you're saying that I need to set_item_property on the item UPDATABLE to true?
in which trigger?
 
Go to help/index/set_item_property and you should find it. Whenever you [set_item_property, enabled, false], Oracle Forms automatically also sets required false, updatable false, insert allowed false and some others. When I am changing a record from false to true I also set insert allowed to true and update allowed to true. those two things are usually enough, but depending upon your other properties, you may require more.

You have to decide which trigger to use, but based on what you have said so far, the when validate item of the field with the LOV sounds like it needs to be there, but in addition you would want to add to the pre-record trigger on the block so that the item is set properly based on the value in that field. You really need to evaluate the different ways the users can get to that record. For example: After they query the record, if the value is not 0 then if you haven't set the item properties there for the descriptive field they may be able to change it depending on the last settings. But you also want it to change when you validate the item with the picklist because you want them able to change the value. So, if they query a record that does not have a '0' then you want that descriptive item disabled to protect it. If they then decide to change it, you will want the when-validate-item to change the values to allow for update before you try to change the contents of the item, but then you may want to re-disable it based on what they entered.

Have I confused you thoroughly? You must remember that if the user can, he will find a way to mess up, so make yourself think like the user. I have met many programmers who don't understand that some users don't follow instructions ... ever. This is the key to success, make sure the user can't mess up the database!
Let me know what else you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top