Home » Developer & Programmer » Forms » How to change master block's data when detail block's data changed? (Forms 10.1.2 Win2003)
How to change master block's data when detail block's data changed? [message #357472] Wed, 05 November 2008 08:49 Go to next message
since
Messages: 18
Registered: May 2008
Junior Member
I have a master block like:
ID, Name, Number
1,  aaa,  44
2,  bbb,  33

detail block like
ID, Operation, Number
1,  ADD,       5
1,  ADD,       22

Related with ID.

The question is, When the detail block record changed (insert/modify/delete), How to update the master block's 'Number' column?

Thanx!

[Updated on: Wed, 05 November 2008 08:50]

Report message to a moderator

Re: How to change master block's data when detail block's data changed? [message #357505 is a reply to message #357472] Wed, 05 November 2008 12:23 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Using one of forms' triggers? WHEN-VALIDATE-RECORD, for example?
Re: How to change master block's data when detail block's data changed? [message #357563 is a reply to message #357505] Wed, 05 November 2008 19:08 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
LF,

We can't do 'restricted' commands in WHEN-VALIDATE-RECORD.

David
Re: How to change master block's data when detail block's data changed? [message #357564 is a reply to message #357472] Wed, 05 November 2008 19:09 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
What is the relationship between 'number' in the detail block and 'number' in the master block because 5 plus 22 is not 44.

David
Re: How to change master block's data when detail block's data changed? [message #357594 is a reply to message #357564] Thu, 06 November 2008 00:16 Go to previous messageGo to next message
since
Messages: 18
Registered: May 2008
Junior Member
djmartin wrote on Wed, 05 November 2008 19:09
What is the relationship between 'number' in the detail block and 'number' in the master block because 5 plus 22 is not 44.

David


The 'number' column do not have any relationship.

For example, I insert an record to the detail block like:

1,ADD,6

the Number in master block of current record should changed from 44 to 50 (44+6=50)

thank you for your reply!
Re: How to change master block's data when detail block's data changed? [message #357595 is a reply to message #357563] Thu, 06 November 2008 00:17 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
djmartin wrote on Thu, 06 November 2008 02:08
LF,

We can't do 'restricted' commands in WHEN-VALIDATE-RECORD.

David

I know; my idea was something like
-- calculations here
:upper_block.number_item := result_of_the_calculation;
but, after your post, perhaps it wasn't that good idea. It appears that it should be more like
-- calculations here
UPDATE upper_block_table SET
  number_column = result_of_the_calculation
  WHERE id = some_id;

GO_BLOCK('uppaer_block');
EXECUTE_QUERY;
which certainly wouldn't be possible in a trigger of my choice.
Re: How to change master block's data when detail block's data changed? [message #357605 is a reply to message #357594] Thu, 06 November 2008 00:48 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Seeing that this is a straight master-detail relationship, and the master record you want to change is this detail record's master then just do a ':blk_mst.number := :blk_mst.number + :blk_dtl.number' in the When-Validate-Item' trigger. You don't have to be IN an item to change it.

David
Re: How to change master block's data when detail block's data changed? [message #357606 is a reply to message #357594] Thu, 06 November 2008 00:49 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
LF,

Sorry, I thought you intended navigating back to the master block from within the WVI trigger at the detail level.

David
Re: How to change master block's data when detail block's data changed? [message #357625 is a reply to message #357605] Thu, 06 November 2008 01:24 Go to previous message
since
Messages: 18
Registered: May 2008
Junior Member
djmartin wrote on Thu, 06 November 2008 00:48
Seeing that this is a straight master-detail relationship, and the master record you want to change is this detail record's master then just do a ':blk_mst.number := :blk_mst.number + :blk_dtl.number' in the When-Validate-Item' trigger. You don't have to be IN an item to change it.

David



Thank you very much! That works! Smile
Previous Topic: XML
Next Topic: Post_insert Trigger
Goto Forum:
  


Current Time: Sun Feb 09 08:57:39 CST 2025