Home » Developer & Programmer » Forms » hw to change value of one field s soon as other field changes
hw to change value of one field s soon as other field changes [message #295485] Tue, 22 January 2008 07:57 Go to next message
isha1812
Messages: 16
Registered: January 2008
Junior Member
Hi
I have a requirement where i need to change the value of one field as soon as i change value of another..

Please suggesr
Re: hw to change value of one field s soon as other field changes [message #295524 is a reply to message #295485] Tue, 22 January 2008 09:47 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
Write your code to change the field in the WHEN-VALIDATE-ITEM trigger on the "other" fields.

By
Vamsi
Re: hw to change value of one field s soon as other field changes [message #295626 is a reply to message #295485] Tue, 22 January 2008 22:48 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
You can use following events:

POST-TEXT-ITEM
WHEN-VALIDATE-ITEM
Re: hw to change value of one field s soon as other field changes [message #295630 is a reply to message #295626] Tue, 22 January 2008 22:53 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Post-Text-Item fires even if the data is NOT changed. This would update the record even though the 'base' data has not been changed. This is unnecessary activity which will muck up any auditing you may create.

David
Re: hw to change value of one field s soon as other field changes [message #295631 is a reply to message #295630] Tue, 22 January 2008 22:59 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
You can check your current value with database_value of the item to verify that the value is changed by the user or not.

[Updated on: Tue, 22 January 2008 23:00]

Report message to a moderator

Re: hw to change value of one field s soon as other field changes [message #295643 is a reply to message #295631] Wed, 23 January 2008 00:09 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Yes and you can reread the whole table to see if another record has been added.

Okay, you change an item from '5' to '6', 'post-text-item' tests the database, there is a difference so you update the other item. You then realise it was the wrong record so you change the '6' back to '5', 'when-validate-item' sees the change but in 'post-text-item' it sees '5' in both places so did does NOT reset the other item.

Just use the trigger that only fires when the data changes and that's 'when-validate-item'.

David
Re: hw to change value of one field s soon as other field changes [message #295645 is a reply to message #295643] Wed, 23 January 2008 00:17 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
The person who raise this post said,
"I have a requirement where i need to change the value of one field as soon as i change value of another.."

So I just suggested him/her to go for these events. As you can see the above senerio is not in detail so what i have said I found it correct.

Both events WHEN-VALIDATE-ITEM and POST-TEXT-ITEM can do the trick. But the really senerio is not clear like how many data or non-base table blocks are there and the field from where the changed value to be observe is in tabular or single record style and that where is that other field there the change value to be copied is it in the same data block or in different data block. And in that field is a base table field or nonbase table field.

So you see my dear friend David the comprehensive the post raised was the comprehensive the reply was.
Re: hw to change value of one field s soon as other field changes [message #295672 is a reply to message #295645] Wed, 23 January 2008 01:17 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
Yes. You are right.
"But" why to assign the same value again and again?

WHEN-VALIDATE-ITEM -> does the required every time when the value changes

POST-TEXT-ITEM -> does the same thing when you navigate from the field whether you change it or not.
Also the question in the OP was
Quote:
hw to change value of one field s soon as other field "changes"


By
Vamsi
Re: hw to change value of one field s soon as other field changes [message #295674 is a reply to message #295645] Wed, 23 January 2008 01:21 Go to previous messageGo to next message
isha1812
Messages: 16
Registered: January 2008
Junior Member
i will write my query in detail

As soon as a owner reassigns the task to another owner then the task status should change to reassigned.

Thanks
Re: hw to change value of one field s soon as other field changes [message #295743 is a reply to message #295674] Wed, 23 January 2008 04:30 Go to previous messageGo to next message
isha1812
Messages: 16
Registered: January 2008
Junior Member
In addition to this there is one more problem as soon as I am opening my form the status has to be changed to be "in progress" and the owner of the task becomes the current user (which I have done).
But if I use when validate item it will not serve the purpose as it will be fired when I open the form also.
Re: hw to change value of one field s soon as other field changes [message #295903 is a reply to message #295645] Wed, 23 January 2008 21:25 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
@azamkhan,

Look at the example I gave. Your statement "Both events WHEN-VALIDATE-ITEM and POST-TEXT-ITEM can do the trick." is incorrect. 'POST-TEXT-ITEM' will work MOST of the time but NOT ALL of the time.

David
Re: hw to change value of one field s soon as other field changes [message #295907 is a reply to message #295743] Wed, 23 January 2008 22:01 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
@isha,

Please give more detail. What do you mean by "in progress"? I don't think this is an Oracle Forms message but something from within the application.

A When-Validate-Item is ONLY fired when an item has had its value changed. If WVI is firing on form startup then something is populating the field in a When-New-Form-Instance trigger or in a trigger that fires before the block or item.

Sorry, but you are going to have to trace the logic of your form. I suggest running it in debug mode from within the Forms Builder.

David
Re: hw to change value of one field s soon as other field changes [message #295910 is a reply to message #295907] Wed, 23 January 2008 22:09 Go to previous messageGo to next message
isha1812
Messages: 16
Registered: January 2008
Junior Member
Thanks you all for your help!

my problem is solved ...i used the "when validate trigger"
Re: hw to change value of one field s soon as other field changes [message #295921 is a reply to message #295903] Wed, 23 January 2008 22:53 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Dear David,

I always like to have different alternatives for a solution, as greate programmers must have more then one alternatives for a solution.

Mr. isha1812 raised a post and I gave different alternatives like POST-TEXT-ITEM and WHEN-VALIDATE-ITEM. Its Mr. isha1812 who knows what is best alternative for his scenario.
Re: hw to change value of one field s soon as other field changes [message #295936 is a reply to message #295921] Wed, 23 January 2008 23:39 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Yes, and look which one he took - When-Validate-Item.

David
Re: hw to change value of one field s soon as other field changes [message #295950 is a reply to message #295921] Thu, 24 January 2008 00:31 Go to previous message
sasipalarivattom
Messages: 121
Registered: June 2007
Location: Cochin ( INDIA )
Senior Member
Hi All,
I think this link is useful here..

post-text-item and when-validate-item

regards
Sasi...
Previous Topic: Table insert using form
Next Topic: I can't rollback changes done by stored procedures
Goto Forum:
  


Current Time: Mon Mar 10 19:35:55 CDT 2025