Statement to give focus to a specific control on a UserForm?

F

Fred Holmes

I would like to put a statement in the intialization code (Private Sub
UserForm_Initialize()) of a UserForm to bring a certain textbox (or
any control) into focus. Something like

TextBox1.hasfocus = True

Is there a way to do this?

When I start to write such a statement in the VBA editor, I dont' find
anything dealing with focus in the list of properties and methods that
appears as context-sensitive help (sort of like a tool-tip)

When the Userform is "showning," the main menu of the Excel workbook
is grayed out, so I don't seem to be able to start the process of
recording a macro to see what the above code might be. Is there any
way to start a macro recording while the UserForm is "showing"? There
is no keyboard shortcut for starting "Record New Macro" on the main
Excel Menus, although I could go into keyboard customization and
assign one.

Thanks for any help.

Fred Holmes
 
B

Bob Phillips

Fred,

Try SetFocus, or even give that control a TabIndex of 1 in the form design
mode.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
F

Fred Holmes

SetFocus works, but why doesn't it show up in the "help" list of
properties and methods? Surely someone at MS has done a basic
completeness check?????

Thanks,

Fred Holmes
 
B

Bob Phillips

Fred,

I am not sure by what you mean. I see SetFocus in the intelli-sense for a
textbox, and if you look up Setfocus in VBA help, it applies to a Textbox.

Where do you expect to see it?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top