Possibly a quite simple answer, but how to put focus to a field in an on validate procedure?


In the property box of a form control, you will see the property called “NextControl”. Assign a Control ID, for the next control that will get focus when a user presses ENTER or TAB.


You can try with CurrForm.“The Field”.ACTIVATE;

If the field is a DB-field, you can already used it. If it is not, you have to give it a name (the name-property of the field).

Thanks for the replies.

Tried to use the CurrForm.“The Field”.ACTIVATE; but get a message that CurrForm is an unknown variable. What I want is to check the entered Social Security No. in an OnValidate procedure at the table. If it is an invalid value then the form field must be cleaned and get the focus.

IF NOT CheckBSN.CheckBSN(“Social Security No.”) THEN
MESSAGE(Text12000000,“Social Security No.”);
“Social Security No.” := ‘’;
CurrForm.“Social Security No.”.Activate;

From table OnValidate trigger you can’t activate field on form.

But if instead of MESSAGE you give ERROR, then user will not be able to leave the field with wrong value. I would change your code to following code:

IF “Social Security No.” <> ‘’ THEN
IF NOT CheckBSN.CheckBSN(“Social Security No.”) THEN
ERROR(Text12000000,“Social Security No.”);

Thanks for the reply. This is workable solution for me.