RunModal: Passing Parameters into a new record

allenmanallenman Member Posts: 37
Hello

I have got stuck with a small project I have been given and hope someone can help.

In summary, I have been allowed to add a button to Form 42 Sales Order. I grab "Sales Order" (and "Line No." from the sub form) information.
I test if this is an existing entry in Form2, if so I open Form2 at that record, if not I pass "Sales Order" and "Line No."
paramters and open Form2 as a new record and pre-enter identical "Sales Order" and "Line No." fields on the
Form2 new record.

The first part, the testing if record already exists in Form2 and if so go there works but I just cannot get what I thought would be the easy part of writing a new record on Form2.

I am still very, very new to Navsion so please bear with me, I have this feeling I have missed something obvious!!

On Form 42 Sales Order
Int_SalesLine is a Global Var of Integer type
(Intially I was going to pass back "Line No." to the main form 42. I will remove this variable when all is working.
PTR - OnPush()
CurrForm.SalesLines.FORM.SendLineNo(Int_SalesLine);
On Form 46 Sales Order Sub Form
Function Name: SendLineNo

Function Local Variables: Rec_SalesLine (Var:Yes - DataType: Integer)
--------------------------------------------------
SendLineNo(VAR Rec_SalesLine : Integer) : Integer
--------------------------------------------------
Rec_SalesLine := "Line No.";

Rec_PTR.SETCURRENTKEY("Sales Order","Line No.");
Rec_PTR.SETRANGE("Sales Order","Document No.");
Rec_PTR.SETRANGE("Line No.","Line No.");

IF Rec_PTR.FIND('-') THEN
BEGIN
CLEAR(Frm_PTR_SalesIn);
Frm_PTR_SalesIn.SETRECORD(Rec_PTR);
Frm_PTR_SalesIn.RUNMODAL;

END
ELSE
BEGIN
CLEAR(Frm_PTR_SalesIn);
Frm_PTR_SalesIn.fctPassFromSalesLine("Document No.","Line No.");
Frm_PTR_SalesIn.RUNMODAL;
END


On Form 50039 PTR
Function Name: fctPassFromSalesLine

Function Local Variables:
PassSalesOrder ( Var:Yes - Datatype:Code 20)
PassLineNo( Var:Yes - Datatype:Integer)
-----------------------------------------------------------------------------
fctPassFromSalesLine(VAR PassSalesOrder : Code[20];VAR PassLineNo : Integer)
-----------------------------------------------------------------------------
GV_Temp_SO_PTR := PassSalesOrder;
GV_Temp_LN_PTR := PassLineNo;

Form2 has identical text boxes of "Sales Order" and " Line No." but I cannot pre-populate these fields with the passed parameters, they are blank.
So, I have temporaily passed the function parameters to two temp variables (GV_Temp_SO_PTR & GV_Temp_LN_PTR ) instead which
are the source expression for two temp text boxes on form 50039 just to prove to myself that the info is actually being passed correctly - and it is.

Sorry for such a long post and hopefully you are still with me.
Thanks in advance for all help.

Regards,
SteveA

Comments

  • zeninolegzeninoleg Member Posts: 236
    Hi SteveA,
    Please correct me if I didn't understand me correctly, but have you tried to clear the record on which your form2 is based then populate your fields on the RECORD and then open your form with this record. Something like this:
    CLEAR(Frm_PTR_SalesIn); 
    Rec_PTR."Document No" := "Document No";
    Rec_PTR."Line No" := "Line No";
    Frm_PTR_SalesIn.SETRECORD(Rec_PTR); 
    Frm_PTR_SalesIn.RUNMODAL;
    
    I hope that helps
    PS and do not forget to increment your line no before creting new record in the table
    Best Regards,
    Oleg
Sign In or Register to comment.