Hi all.
I have the following situation.
I have created a SubTable that is connected to the Sales Lines. When the user edits a specific sales line, he can press Shift-F9 and open the table SubTable in a form called SubForm that displays info relative to the specific Sales Line record.
The client has requested that the wants to simulate the following functionality with one button click from inside the subform : create a new sales line using the same Item No from the previous record and create a new line for the SubTable connected to the new Sales Line. All this without leaving the subform.
I have created this functionality, but I need to set the focus on the new Sales Line record BEFORE the user closes the SubForm, so that the SubForm shows the new SubTable record.
Any help?
Jorgito
0
Comments
Create some variables in codunit which detect your sales line
create variable of type Codunit Session in form with sales line and in SubForm
define Session variables In SubForm
Read this variables In form with sales line and use GET
I did it. It works
So I think to use OnTimer at form with sales line. OnTimer must check the variable at codunit Session
Imagine that the parent form shows record P1 which is linked to the S1 record in the SubTable. While the SubForm is open (modally), I want to move the record in the parent form to P2 and so show in the SubForm record S2 (which is linked to P2).
How can I make a variable of the record in the parent form be accessible in the child form. I tried
SalesLineChars.SetParentSalesLine(Rec);
SalesLineChars.RUNMODAL;
where SetParentSalesLine is
SetParentSalesLine(VAR ParentSalesLine : Record "Sales Line")
SalesLine.COPY(ParentSalesLine);
and when the button is clicked I do
SalesLine2.INIT;
SalesLine2.VALIDATE("Document Type", "Document Type");
SalesLine2.VALIDATE("Document No.", "Document No.");
SalesLine2.VALIDATE("Line No.", LineNo);
SalesLine2.VALIDATE(Type, SalesLineTemp.Type);
SalesLine2.VALIDATE("No.", SalesLineTemp."No.");
SalesLine2.INSERT;
SalesLine := SalesLine2;
I imagine that, since SalesLine (inside the subform) was copied from the Rec variable of the parent form, inserting a record would move the cursor to the new record. But it doesn't.
Please, need desperate help!!
Jorgito
try:
SalesLine2.INIT;
SalesLine2.VALIDATE("Document Type", SalesLine."Document Type");
SalesLine2.VALIDATE("Document No.", SalesLine."Document No.");
SalesLine2.VALIDATE("Line No.", SalesLine.LineNo);
SalesLine2.VALIDATE(Type, SalesLineTemp.Type);
SalesLine2.VALIDATE("No.", SalesLineTemp."No.");
SalesLine2.INSERT;
br
Josef Metz
Josef Metz
Let me point out that SalesLine is the record I have in the subform that I want to directly reference the records in the parent form.
Have you tried to create the record before you run the form? So new the record is created before you call the form.run...
I have a button in the Sales Orders that when it is pressed, it shows the SalesLineChar record for the chosen Sales Line record.
What I want to do is, while showing (modally) the SalesLineChars form, to insert a new line in the Sales Line table and display the (new) record of the SalesLineChar table.
Something like a) close the SalesLineChars form, b) insert a new Sales Line, c) Open the SalesLineChars form again (for the inserted record), WITHOUT CLOSING THE FORM. Just by clicking on a button in the SalesLineChars form.
It is a very complicated situation and the client is quite paranoid, so I have to find a solution for this by Friday.
Please help.
A) So you open a form from an existing sales line showing existng char record
You automaticaly create a new sales line and connected char record
C) You want to focus on the new char record
If this is right you can try changing the order
Create the new salesline + char record
A) Open the form, using the new char record
C) is done automaticaly.
If this is not possible you can try to use the GET statement in step C.
I cannot change the order, because the subform showing the (old) char record is already open and I want to create a new sales line + char WITHOUT CLOSING THE SUBFORM.
Like
NewChar.INSERT;
GET(NewChar.Keyfields)
If this does not work, just tell, then we need to be more creative.
SalesLine.INSERT;
SalesLine.GET;
SubForm.UPDATE;
So now, the SubForm shows the NewChar (because the active record is NewSalesLine)
Since the Subform is connected to the SalesLineSubform using Document Type, Document No and Line No, if I insert a new line in Char, it won't show, because the active Char line is OldChar and the active Sales Line line is OldSalesLine.
I am pretty sure we must be creative. My deadline is tomorrow and I am running out of time.....
Thanks in advance for all the help you have (will) given me!!
Jorgito