How to configure Focus in a text box in a form upload

Work in A2003 and A2007.

How do we guarantee that the selected TextBox gets focus when loading the form? If we put MyTextBox.SetFocus in Form_Load, we get an error:

can't move the focus to the control

This form is designed for quick data entry, and the form is somewhat rebuilt based on the latest settings used. Thus, there are several different text fields that may need focus depending on the user. We cannot just fix this during development by setting MyTextBox TabIndex = 0.

The help talks about a redraw call, which just doesn't make any sense:

You can only move focus until visible control or shape. The form and controls on the form are not visible until the Load finished event appears. Therefore, if you use the SetFocus Method in the Load event form to move the focus to this form, you must use the Repaint method before the SetFocus Method.

+3
source share
4 answers

You cannot set the focus because the controls do not exist yet, try entering the code in the OnActivate event instead

Or just put DoCmd.Repaint in the OnLoad event before trying to set focus. Both should work, but I'm not near the computer to check

+1
source

, 0 Index Index.

+1

, , , , 1) , 2) . , , (, , ).

.SetFocus . , - , , .

, , , header/footer , . , "" , , SetFocus. , , .

+1

SetFocus On . , , , , Allow Additions . SetFocus, .

+1

Source: https://habr.com/ru/post/1794699/


All Articles