Passing parameter to dataport

Hello,

I would like to export some records using dataport.

I have a form (Header) with a subfrom (Lines). I want to export records from Lines, filtered by a field from Header.

In dataport I use Lines as DataItem. I have a function in dataport:

SetCode(Code : Code[10])
BTCode := Code;

I call the dataport from menu item on the form like this (dp is the dataport, Code is the field of the Header, which I use for filtering):

OnPush():

dp.SetCode(Code);
DATAPORT.RUNMODAL(50010);

After trying this, BTCode is empty, the parameter is not passed to the dataport.

Any idea about what I am doing wrong?

Thanks a lot, Frida

OnPush()

Purchline.RESET;
Purchline.SETRANGE(“Document Type”,“Document Type”);
Purchline.SETRANGE(“Document No.”,“No.”);
Purchline.SETRANGE(Purchline.Type,Purchline.Type::Item);
DATAPORT.RUNMODAL(50010,TRUE,Purchline);

*Code assumes it’s from a purchase order. If Sales Order change PurchLine to SalesLine.

Save->Compile->Enjoy!