×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Excel Autotab

Excel Autotab

Excel Autotab

(OP)
I have a userform with a combobox, textbox and button set in that sequence in the tab order. The combobox and the text box both have autotab enabled, this automatically tabs to the next item when enter is pressed.

Can I make the button behave in the same way?

I tried to use VBA code to cause the first tab item to be selected after the button was clicked but I have had no luck.

RE: Excel Autotab

Not sure which application you are using, but from the Excel VBA Help file:

AutoTab Property
Specifies whether an automatic tab occurs when a user enters the maximum allowable number of characters into a TextBox or the text box portion of a ComboBox


and in the Applies To list:
ComboBox Control
TextBox Control


This property would appear to have no use in the context of a CommandButton.


Regards,
Mike

RE: Excel Autotab

Just select the other control that you want to select at the end of the click event for the button.

RE: Excel Autotab

Most controls have a SetFocus Method - use that at the end of the Command click event code

CODE

Private Sub CommandButton1_Click()
'do the other click things here like maybe
'ComboBox1.AddItem TextBox1.Text
'then set focus to the Textbox
TextBox1.SetFocus
End Sub

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

RE: Excel Autotab

(OP)
Thanks, I could only find select case in the help files (after reading AliThePro's advice). I am used to Excel commands so I was searching for things like select, activate & move to which all went nowhere.

RE: Excel Autotab

(OP)
I have used the SetFocus method but when the focus is set on the combo box I can only scroll through existing text. If I want to enter new text or even modify existing text (use the delete key to remove letters) I have to either click in the box or tab out of focus then tab back into the box.

It is nice to be 1 step closer to the goal but any additional help is appreciated. The VBA help does not list any methods applicable to the combo box which might do what I need.

I will try looking at methods for related objects.

RE: Excel Autotab

Look at the SelStart property

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

RE: Excel Autotab

(OP)
It seems the SelStart property can only return the cursor position. I can't figure out how to set the cursor position.

RE: Excel Autotab

To position the cursor at the start:

CODE

Textbox1.SelStart = 0
To get to the end

CODE

Textbox1.SelStart = Len(Textbox1.Text) + 1

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

RE: Excel Autotab

(OP)
Not working as suggested.

Could it be that I am using a ComboBox rather than a TextBox?

RE: Excel Autotab

Sorry, my bad! I was thinking about the TextBox still. To select a particular item in a ComboBox, use the ListIndex property (zero based)

ComboBox1.ListIndex = 1

will select the second item in the list

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources