Return Focus to Main form field

DatapacDatapac Member Posts: 97
Hi,

I've designed a new version of the Sales Order form and subform where the control should work as follows:

MainForm.SellToCust - TAB
SubForm.No - TAB
SubForm.Qty - TAB
SubForm.No - TAB
SubForm.Qty - F6 -> Create new Order returning focus to SellToCust

The problem I have is with the returning focus to SellToCust after creating the new order. Here's the code I'm using behind the F6 menu-button:
// Save Current Record
CurrForm.SAVERECORD;
COMMIT;

// Initialise New record
INIT;
"Document Type" := "Document Type"::Order;
"No." := '';
INSERT(TRUE);
COMMIT;
SETRANGE("No.");

IF xRec."Journey Code" <> '' THEN BEGIN
  "Journey Code" := xRec."Journey Code";
  MODIFY;
  COMMIT;
END;

// CurrForm."Sell-to Customer No.".ACTIVATE;

If I put in the code commented out above (i.e. CurrForm."Sell-to Customer No.".ACTIVATE;), I get an message asking do I want to Rename the Record.
If I say Yes to this message I get a message saying I'm not allowed rename a Sales Header. If I say No, the new order is created but the Form stays on the previous order.

Leaving out this line of code results in the Form displaying the new Sales Header record but focus remains on Subform.Qty field.

Any ideas?

Thanks in advance,
Richie

Answers

  • krikikriki Member, Moderator Posts: 9,110
    Try to put a Currform.UPDATE(FALSE); just before the CurrForm."Sell-to Customer No.".ACTIVATE;
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • DatapacDatapac Member Posts: 97
    Thanks Alain, that's sorted it!
  • GoMaDGoMaD Member Posts: 313
    I'm trying to do the exact same thing in 4.00 SP3 and i can't get the focus to switch to the "Sell-to Customer" control on the main form. It remains in the subform.

    Any idea's?

    Regards,
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • krikikriki Member, Moderator Posts: 9,110
    Try to put property DelayedInsert=Yes in the subform.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • GoMaDGoMaD Member Posts: 313
    It's on the Sales Invoice form, so the DelayedInsert property is already set to true.
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • krikikriki Member, Moderator Posts: 9,110
    Maybe some ActiveControlOnOpen-property? Or some hidden code that activates the subform?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.