MrExcel Publishing
Your One Stop for Excel Tips & Solutions

userform textbox w/cursor in it by default when opened (repost)

Posted by rm on January 04, 2002 5:54 PM

how do I get a textbox to have cursor in it by default when a userform opens?...btw, the userform has a multipage control on it with page1 and page2...the first textbox on page1 is the textbox I would like the cursor to appear in by default when the userform is opened...thanks...rm

Posted by Bariloche on January 04, 2002 8:09 PM


The following code lines should get you headed in the right direction:

UserForm1.MultiPage1.Value = 0

You should modify these lines to use the actual name of your text box. A good programming practice is to rename controls so that the name reflects what the control does. For example, your first text box might be for "Pets Name" and so you could call your control txtPetsName, rather than TextBox1. Likewise the form should have a name like frmMyPets. And so on with all your controls.

have fun

Posted by Jacob on January 04, 2002 8:22 PM


In VB make sure the userform has the page you want to start up with on top then put this code in:

end sub

Posted by rm on January 06, 2002 4:23 PM

thanks Jacob and Bariloche... great!