Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Automatically have Text Cursor in Text Box (as Opposed to Command Button Selected) in Form?

I have two Excel picture objects linked to different forms, each with a text box and OK/Cancel buttons. In one form, the text cursor is in the textbox when clicking the object which is what I want:

Correct

but in another it selects the OK command button rather than have the text cursor in the textbox:

Incorrect


I've gone through the form and textbox/command button properties and see nothing about selection, and the 'correct' macro properties appear to be the same as the 'incorrect' one.

What do I do to change the form such that when it's opened the text cursor goes to the textbox instead of the command button being selected?

like image 953
Kurt Wagner Avatar asked Dec 08 '22 14:12

Kurt Wagner


1 Answers

Quite easy solution is to change TabIndex Property to 0.

So, 1) go to VBA Editor, 2) select your TextBox in your UserForm and 3) change TabIndex Property in Property window as presented below.

enter image description here

like image 156
Kazimierz Jawor Avatar answered Mar 16 '23 20:03

Kazimierz Jawor