SetFocus
This command is used to reposition the focus to a specific prompt or the TabNo (tab number) assigned to a specific prompt.
App.SetFocus should be the last statement for an event since subsequent statements will be ignored.
If the optional SaveRSP parameter is used the data entered for the current prompt will be saved in the current record, prior to the App.SetFocus. The SaveRSP flag does not apply to the Rsp variable in the OnEnter event but will only save the text in the textbox itself. To alter the textbox value in code use the RFPrompt(1).Text property and give it a value.
The ValidateRSP flag will check the text value against the Edits property and also execute the OnEnter event. This makes the most sense when the SetFocus method is used in an event other than the OnEnter event. If the SetFocus method is used in the OnEnter event the ValidateRSP flag will not process the edits again or run through the OnEnter event a second time. Be sure not to cause one SetFocus command to execute another SetFocus command as this may lead to unintended results.
Group: Application-Based Extension
Syntax: [bValue =] App.SetFocus (vFieldId, [bSaveRSP], [bValidateRSP])
bValue (Boolean) Optional – Returns True or False depending on the success of the command
vFieldId (Variant) is the prompt’s Field Id or number receiving the focus.
bSaveRSP (Boolean) Optional – set to True to save any changes to the current prompts value before switching focus to the new prompt.
bValidateRSP (Boolean) Optional – set to True to call the edit checks and to re-run the OnEnter event.
Example:
App.SetFocus(5) ' Cursor will go to prompt #5
App.SetFocus("PartNo") ' Focus goes to PartNo prompt
App.SetFocus("PartNo", True, True) ' Cursor will go to "PartNo", save current Text property and execute edits and OnEnter event
'Moves the cursor to the next prompt that is two tab numbers higher than current prompt.
App.SetFocus(RFPrompt(App.PromptNo).TabNo + 2)
Version Supported: RFgen 4.0, 4.1, 5.0, 5.1, 5.2 and newer.