Lotus Notes FAQ Visit Our Sponsor!

How do you update another form with information from the current form?


Both forms must have a unique key field (a formula for this can be found here). There must be a hidden view of the destination documents with the first column being the unique key. Variables are passed using environment variables. This code would go in the source form's update button:
@If(@IsNewDoc; ""; @Do(@Command([FileSave]); 
@Command([FileCloseWindow]); @Return("")));     
ENVIRONMENT CTDB1 := @Trim(UniqueID);
ENVIRONMENT CTDB5 := @Trim(@Text(Qty));
@Command([OpenView]; "(SpecialView1)"; CTDB1);
@Command([ToolsRunMacro]; "(UpdateReceivedQty)");
@Command([FileSave]);
@Command([FileCloseWindow]);
@Command([FileSave]);
@Command([FileCloseWindow]);
@Command([EditDocument])

The UpdateReceivedQty macro would then do the following:

FIELD QtyInStock := QtyInStock;
@If(UniqueId != @Environment("CTDB1"); @Do(@Prompt([OK]; "Error"; "UniqueId Number " + @Environment("CTDB1") + "cannot be found"); @Return("")); "");
@SetField("QtyInStock"; (QtyInStock + @TextToNumber(@Environment("CTDB5"))));
SELECT @All

Applies to Notes Versions: 3
Last Modified: April 17, 1996