MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Changing Focus and cursor to Textbox

  Asked By: Darcy    Date: Mar 11    Category: MS Office    Views: 1118

I have an accounting macro associated with an excel spreadsheet that
supports a userform with the following:

Textbox for date of transaction
Textbox for ammount of transaction
Several optionbuttons on a frame on the userform
Command button to enter data
Command button to exit the macro
Text box for a comment.
Three labels associated with the textboxes

The macro works fine as it is. I usually enter the data and then tab
to the next field, including tabbing through the option buttons on
the frame to select which classification to give to this entry. Each
optionbutton is associated with a classification. Only occasionlly do
I need to enter a comment. Usually I tab through the option buttons
although I could mouse click on the one I want.

What I would like to do is when I select an option button with the
mouse to have not only that option button selected (that works OK
now), but also to have the focus and cursor immediately in the
comment textbox so I can enter a comment without first clicking in
that field. Currently after chosing an optionbutton with the mouse I
then have to also click in the comment text box before I can enter
the text there. I still would like to be able to tab through the
fields, including the optionbuttons, when there is no comment.

After entering all the data, including the comment if needed, I
either mouse click on the "enter data" command button on the userform
or hit the enter key on the keypad to enter the data onto the excel

Is this possible? How do I get the focus and cursor into the comment
textbox as an additional result of clicking on an optionbutton?



1 Answer Found

Answer #1    Answered By: Flynn Jones     Answered On: Mar 11

The comment  text box  has to grab the focus. I.e. insert

Call MyCommentTextBox.SetFocus

at the end of your option button  processing.

Didn't find what you were looking for? Find more on Changing Focus and cursor to Textbox Or get search suggestion and latest updates.