Connecting Tech Pros Worldwide Help | Site Map

How to set focus to text box on subform if name of the control if public var.

Newbie
 
Join Date: Feb 2009
Posts: 16
#1: Aug 17 '09
Situation: A form is opened containing subform, contents of subform is changing dynamically on form Open. I would like to have the first text box of subform under focus. Before opening, the name of the control is assigned to pubFirstControl variable.
So far I could not find the way to solve this problem.
Any hints?
Newbie
 
Join Date: Feb 2009
Posts: 16
#2: Aug 18 '09

re: How to set focus to text box on subform if name of the control if public var.


Solving the same problem I have encountered the following next one:
I can set focus using statement

Forms![F20]![FormSec].SetFocus

However, at each moment the name of the form opened (F20 in the example above) is stored in variable PubCurForm. But i have not found any reasonable way to use the above statement with variable in place of Form name.
Code like

Select PubCurForm
case "F20" Forms![F20]![FormSec].SetFocus
....

is not an elegant solution.

Who knows better way?
Reply

Tags
name in variable, setfocus, subfrom