placing focus on a control at run time

How can we place focus on a certain control at run time? look at the eg below suppose 2 fields orgin and finaldestination. i want the user to enter value into “origin” field before he enters value into “final destination”…but if the user directly goes to the finaldestination field to enter data without entering values in the origin field then the user should be given a message and the focus has to be placed on the origin field. i have written the code this way onActivate if origin = ‘’ then currform.origin.activate; but the system places the focus on the first field on the left side of the tab… thanks in advance kumar

Try to insert the “origin” field activation code into OnAfterGetRecord form trigger. The field activation will run in case of initial form open and in case of records searching (PgUp/PgDn).

// The trial form uses country table
IF "Intrastat Code" = '' THEN
  CurrForm."Intrastat Code".ACTIVATE;
// ----------------------

Regards, Yuri Pokusaev IBS, Senior Consultant NCPS, NCSD +7(095)967-8080

Kumar - I did somewhat the same thing some time ago. I found that you need to activate the control before the contron you want to activate. (That did not sound right, did it?) Example: Let’s say you have a table like this, and a for for entering; I type <> Item, then Quantity should be 1 and go directly to Unit Price

Customer No   Type  Item No   Quantity   Unit Price

[Type - OnValidate (table)]
if type <> type::item then
  Quantity := 1;

[OnAfterValidate - form]
if type <> type item then
  currform.Quantity.Activate (This will in fact activate the "Unit Price"
  currform.Type.Activate (This will activate "Item No.")

//Henrik Helgesen -: KISS::Keep it Simple, Stupid :-