Focus on subform

Hi all, I have added funcionality to the “Purchase invoice” form and now I want to restrict it to the lines so that the option only works when the focus is on the subform. I have tried using OBJECTID but it seems that Navision always interprets the parent control as having focus. I am open to solutions (command button disabled, error message, etc.) and I would really appreciate if anyone knows how to work around this. Regards, Eyrún

Hi Eyrun! I suppose you and Miguel Alonso are asking about the same problem!? http://www.navision.net/forum/topic.asp?TOPIC_ID=4773 Maybe you could do this: Create a global variable in InvoiceHeader-Form, e.g.

ActiveForm, Type Option, Options: Header,Lines

Now you could set this variable in the OnActivate and OnDeactivate Triggers of the Control “PurchaseLines” of the Main-Form.

OnActivate()
ActiveForm := ActiveForm::Lines;
...
OnDeactivate()
ActiveForm := ActiveForm::Header;

Then you could decide, what function should be run:

CASE ActiveForm OF
  ActiveForm::Header: ...  // do this
  ActiveForm::Lines : ...  // do that
END;

Regards, Jörg

Hi Jörg, You’re right - MA was trying to help me. The thing is I have a button on the main form to perform actions upon the lines. I don’t want the users to accidentally change a line so I thougt if I could condition the behaviour of the button according to whether the user has selected a line or is still in the header, I could prevent errors. But of course, the button is on the main form so I suppose that clicking on it moves the focus anyways so I don´t know if this has a solution… Thanks, Eyrún