Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using "tab" to move from control to control

Status
Not open for further replies.

jsnel

Technical User
Jul 21, 2002
9
US
Hi all,
I have created a data entry area on a worksheet...not a form...using txt box and combo box controls...my problem that I am having is when I run the sheet I cannot use the tab key to easily move the cursor from one control to the next. I understand that if I had created these controls in a form there is a properties feature that sets the tab...Without re-creating my fields in a "form"...How can I keep my "embedded" form format BUT enable the tab function?

Any suggestions is appreciated!
 
You can use the KeyDown event of the control to do what you want. For example if you have 2 Textboxes on your sheet, when you are in TextBox1 and hit th eTab key, the following code will activate TextBox2 :
Code:
Private Sub TextBox1_KeyDown( _
        ByVal KeyCode As MSForms.ReturnInteger, _
        ByVal Shift As Integer)
        If KeyCode = 9 Then Me.TextBox2.Activate
End Sub
[code]
You can apply the same eventt to each control, just changing the next control to activate.

A.C.
 
acron,
Thanks. With this code I am able to move from one control as expected...however, when the cursor moves to the next control, the control textbox although active is not visible until I type a character in the box. Also, when I advance the cursor to a combobox control the ListFillRange I set in the properties window is overwritten (for lack of better term) I suspect this may have something to do with not using GotFocus ...I may be off, but it seems that once the object is active... I then need to build the combo list directly in the code side vs. using a named range. Please advise.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top