Updating a second record based on changes to first record

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
yahya
Posts: 77
Joined: Sat Jul 16, 2011 6:00 am
Location: South Africa
Contact:

Updating a second record based on changes to first record

Post by yahya »

Run into a dilemna not sure how to update a secondary item when updating the first record, need some clues.

Am working on stock management transferring stock quanties from one product warehouse to another product warehouse.

Am presuming I would need to first find the related record which will go something like this:

FIND ProductControl WHERE StockTransferLineItem.Items.ItemCode=ProductControl.ItemCode AND StockTransferLineItem.DeliverTo=ProductControl.Warehouses

However once find how do I get the item updated with a new stock quantity, would imaging something like:

SET ProductControl FROM StockTransferLineItem WITH ProductControl.CurrentStock=ProductControl.CurrentStock+StockTransferLineItem.Quantity

But I know this is wrong just looking for the correct way, any assistance would be greatly appreciated.
pbrad
Posts: 781
Joined: Mon Jul 17, 2006 11:03 pm
Location: Ontario, Canada

Post by pbrad »

Hi,
All you need is:

ProductControl.CurrentStock=ThisProductControl.CurrentStock+ThisStockTransferLineItem.Quantity

Cheers,
Pete
Pete Bradstreet
Contract developer of commercialized applications

AwareIM Ver. 8.2
yahya
Posts: 77
Joined: Sat Jul 16, 2011 6:00 am
Location: South Africa
Contact:

Post by yahya »

Thanks for the feedback, worked like a bomb.

And I now got to see how to apply a This,
pbrad
Posts: 781
Joined: Mon Jul 17, 2006 11:03 pm
Location: Ontario, Canada

Post by pbrad »

No worries, you might also want to modify your FIND statement slightly from:

FIND ProductControl WHERE StockTransferLineItem.Items.ItemCode=ProductControl.ItemCode AND StockTransferLineItem.DeliverTo=ProductControl.Warehouses

To:

FIND ProductControl WHERE (StockTransferLineItem.Items.ItemCode=ThisProductControl.ItemCode AND StockTransferLineItem.DeliverTo=ThisProductControl.Warehouses) IN BATCHES OF 1

Cheers,
Pete
Pete Bradstreet
Contract developer of commercialized applications

AwareIM Ver. 8.2
Post Reply