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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab or Enter from a combobox?

Status
Not open for further replies.

Thwarted

Technical User
Oct 10, 2002
32
CA
this could be a dumb question but how to you set a combo box so you can tab - or even enter from it?

Thanks!!
 


Hi,

What kind of control?

Where is the control?

What application?

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I have a combobox in Excel - well a few of them and i want to be able to tab from one to the next or to the next cell
 



Can't on a sheet. You can only tab from cell to cell.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
woohoo!

I figured how to do it with code

Thanks!
 



Please share your success.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Here is what I ended up with
I cant take credit a friend of mine sent me similar code that i could make fit what i needed.

Sub ComboBox4_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Select Case KeyCode
Case 9 'Tab
ComboBox5.Activate
Case 13 'Enter
ComboBox5.Activate
Case Else
'do nothing
End Select
End Sub
 



rather than hard-coding the tab sequence into each control, why not make a tab sequence table, that can easily be changed, and code ALL your controls identically to get the next/prev control from the table.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi Skip

I am answering a question from a long time ago - I had left this as it was working but now have some time to clean it up.
I am not sure how to do what you described with the table - but that sounds like it would be much cleaner! I have multiple sheets that each have combo boxes.

Is the table something that is easy to do?

Thanks!!
 


I have 3 TextBoxes on my sheet.
Code:
Sub sel(KeyCode, shift, Nam)
    Select Case KeyCode
        Case 9 'Tab
            NextBox Nam
        Case 13 'Enter
            NextBox Nam
        Case Else
            'do nothing
        End Select
End Sub
Function NextBox(Nam)
    Dim r As Range
    For Each r In [CtrSeq]
        If r.Value = Nam Then
            ActiveSheet.Shapes(r.Offset(0, 1)).OLEFormat.Activate
            Exit For
        End If
    Next
End Function
Sub TextBox1_KeyDown(ByVal _
        KeyCode As MSForms.ReturnInteger, _
        ByVal shift As Integer)
    
    sel KeyCode, shift, TextBox1.Name
End Sub

Sub TextBox2_KeyDown(ByVal _
        KeyCode As MSForms.ReturnInteger, _
        ByVal shift As Integer)
    
    sel KeyCode, shift, TextBox2.Name
End Sub
Sub TextBox3_KeyDown(ByVal _
        KeyCode As MSForms.ReturnInteger, _
        ByVal shift As Integer)
    
    sel KeyCode, shift, TextBox3.Name
End Sub
My Table, using Named Ranges...
[tt]
CtrSeq NextCtr

TextBox1 TextBox3
TextBox2 TextBox1
TextBox3 TextBox2

[/tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top