How to pass value between the Forms?

Hi Forum,
First of all, I am apologize if the description is kind of long.

In Form Transfer Order (F 5740), after User creating the Transfer Order Number on the Header, I want to have a function that allow the User to copy the “item no, description, quantity, order no, container no, etc “ from Purch. Receipt Lines (Form 5806).
The problem that I have is that the Transfer Line. “Document No.” is BLANK and failed to capture the value from the Transfer Header.”No”.
Everything else (“item no, description, quantity, order no, container no, etc “ from Purch. Receipt Lines) were inserted correctly to the Transfer Line table.
I’ve trying many ways to populate the “Document No” without any luck. [:’(] Please HELP!

Here is what I’ve done:

· Form 5806 – on Push () trigger, I added the following code:

FromPurchRcptLine.COPY(Rec);

CurrForm.SETSELECTIONFILTER(FromPurchRcptLine);

IF FromPurchRcptLine.FIND(’-’) THEN BEGIN

CreateRcptLines(FromPurchRcptLine,TransferLine,TransferHeader);

END;

CurrForm.CLOSE;

CreateRcptLines(VAR FromPurchRcptLine : Record “Purch. Rcpt. Line”;TransferLine : Record “Transfer Line”;TransferHeader : Record "Transfer Header”)
IF NOT TransferLine.RECORDLEVELLOCKING THEN
TransferLine.LOCKTABLE(TRUE,TRUE);
NextLine := TransferLine.“Line No.”;
TransferLine2.SETRANGE(“Document No.”,TransferLine.“Document No.”);
TransferLine2.SETRANGE(“Line No.”,TransferLine.“Line No.”);
REPEAT
TransferLine2.SETRANGE(“Item No.”,FromPurchRcptLine.“No.”);
TransferLine2.SETRANGE(“Container/Shpt Release No.”,FromPurchRcptLine.“Container No.”);
TransferLine2.SETRANGE(“PO No.”,FromPurchRcptLine.“Order No.”);
TransferLine2.SETRANGE(“Document No.”,FromPurchRcptLine.“Document No.”);
TransferLine2.SETRANGE(“Line No.”,FromPurchRcptLine.“Line No.”);
IF NOT TransferLine2.FIND(’-’) THEN
BEGIN
TransferLine.“Document No.” := TransferHeader.“No.”;
TransferLine.“Item No.” := FromPurchRcptLine.“No.”;
TransferLine.“Variant Code” := FromPurchRcptLine.“Variant Code”;
TransferLine.“Unit of Measure” := FromPurchRcptLine.“Unit of Measure”;
TransferLine.“Unit of Measure Code” := FromPurchRcptLine.“Unit of Measure”;
TransferLine.“Container/Shpt Release No.” := FromPurchRcptLine.“Container No.”;
TransferLine.“PO No.” := FromPurchRcptLine.“Order No.”;
TransferLine.Quantity := FromPurchRcptLine.Quantity;
TransferLine.“Qty. to Ship” := FromPurchRcptLine.Quantity;
TransferLine.“Outstanding Quantity” := FromPurchRcptLine.Quantity;
InsertTransferLines(TransferHeader,TransferLine,FromPurchRcptLine.“Document No.”,FromPurchRcptLine.“Line No.”,
FromPurchRcptLine.“No.”,FromPurchRcptLine.Description,NextLine);
END;

InsertTransferLines(TransferHeader : Record “Transfer Header”;TransferLine : Record “Transfer Line”;ApplToDocNo2 : Code[20]; ApplToDocLineNo2 : Integer;
ItemNo2 : Code[20]; Description2: Text [100]; NextLineNo : Integer);
NextLineNo := NextLineNo + 10000;
TransferLine2.INIT;
TransferLine2.“Document No.” := TransferLine.“Document No.”;
TransferLine2.“Line No.” := NextLineNo;
TransferLine2.“Item No.” := TransferLine.“Item No.”;
TransferLine2.“Variant Code” := TransferLine.“Variant Code”;
TransferLine2.“Container/Shpt Release No.” := TransferLine.“Container/Shpt Release No.”;
TransferLine2.“PO No.” := TransferLine.“PO No.”;
TransferLine2.Quantity := TransferLine.Quantity;
TransferLine2.“Qty. to Ship” := TransferLine.Quantity;
TransferLine2.“Quantity (Base)” := TransferLine.Quantity;
TransferLine2.“Outstanding Qty. (Base)” := TransferLine.Quantity;
TransferLine2.“Outstanding Quantity” := TransferLine.Quantity;
TransferLine2.“Unit of Measure” := TransferLine.“Unit of Measure”;
TransferLine2.“Unit of Measure Code” := TransferLine.“Unit of Measure Code”;
IF Item.GET(ItemNo2) THEN BEGIN
TransferLine2.Description := Item.Description;
TransferLine2.“Gen. Prod. Posting Group” := Item.“Gen. Prod. Posting Group”;
TransferLine2.“Inventory Posting Group” := Item.“Inventory Posting Group”;
IF TransferLine2.“Gross Weight” <> 0 THEN
TransferLine2.“Extended Gross Weight” := TransferLine.Quantity * Item.“Gross Weight Per UoM (lbs)”;
END;
TransferLine2.INSERT;

Thanks in advance!

ZB

Have you check How Navision copy document functionality works ?

Yes I have. I found this is different with copy document functionality.

I think I see the problem … in your CreateRcptLines function:

IF NOT TransferLine2.FIND(’-’) THEN BEGIN

TransferLine.“Document No.” := TransferHeader.“No.”;

TransferLine.“Item No.” := FromPurchRcptLine.“No.”;

On the second line of this snippet, you’re assigning the value of TransferHeader.“No.” to TransferLine.“Document No.”, but I don’t see any place in your code where you’re getting or finding the TransferHeader record. If that’s the case, then at the time of this assignment statement, TransferHeader is blank.