Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
unexpected cursor behavior while attempting to control tab order intextboxes and comboboxes on a spreadsheet.
Hi,
Windows 2000 professional, Excel 2000 When I type in textbox4 or textbox 7, every other character is deleted when I press tab or enter, so if I type AB [enter], only "A" shows in the textbox. Textbox 3 has behavior that I expect. If I type "ABC" [enter], then "ABC" is what shows in the textbox. I have 10 comboboxes and textboxes placed on a worksheet, not a userform: Part Number combobox1 Connector Code textbox2 Customer Ref Number textbox3 Competitor Part Number textbox4 Customer combobox5 Formula combobox6 Shell Size textbox7 Entry Size textbox8 Chain combobox9 Mod Code combobox10 I don't see this behavior with the comboboxes using similar code. Here's the code for each text box mentioned above and for the first combobox on the sheet. Please offer any insight how to improve this attempt at controlling tab order on textboxes and comboboxes. Private Sub combobox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Application.Calculate 'Part Number-This is the field to type the part number we're quoting 'I named these objects by object type and tab order number. 'Add functionality to the Enter, Tab and Backspace keys Select Case KeyCode Case 9 'Tab Move Cursor to Connector Code or Reference Part Number with shift If CBool(Shift And 1) Then TextBox4.BackColor = RGB(152, 255, 152) TextBox4.Activate Else TextBox2.BackColor = RGB(152, 255, 152) TextBox2.Activate Application.Calculate End If Case 13 'Enter Move Cursor to Connector Code or Reference Part Number with shift If CBool(Shift And 1) Then TextBox4.BackColor = RGB(152, 255, 152) TextBox4.Activate Else TextBox2.BackColor = RGB(152, 255, 152) TextBox2.Activate Application.Calculate End If Case 8 'Backspace ComboBox1.SelText = "" If ComboBox1.SelStart 0 Then _ ComboBox1.SelStart = ComboBox1.SelStart - 1 ComboBox1.SelLength = Len(ComboBox1.Text) - ComboBox1.SelStart Application.Calculate Case Else ' Do nothing End Select Application.Calculate End Sub __________________________________________________ Private Sub TextBox4_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) ' Application.Calculate 'Competitor Part Number field. The user enters the competitor part number here, presses tab 'or enter to call the sql to retrieve our part number from the access database EAIQuote.mdb. 'I named these objects by object type and tab order number. 'Add functionality to the Enter, Tab and Backspace keys Select Case KeyCode Case 9 'Tab Move Cursor to Competitor Part Number If CBool(Shift And 1) Then ComboBox1.BackColor = RGB(152, 255, 152) ComboBox1.Activate Else If TextBox11.Value < "" Then ComboBox1.BackColor = RGB(152, 255, 152) ComboBox1.Activate Else TextBox11.SelText = Replace(TextBox4.Text, "-", "") CreateRecordSet ComboBox1.BackColor = RGB(152, 255, 152) ComboBox1.Activate End If End If Application.Calculate Case 13 'Enter Move Cursor to Connector Code If CBool(Shift And 1) Then ComboBox1.BackColor = RGB(152, 255, 152) ComboBox1.Activate Else If TextBox11.Value < "" Then ComboBox1.BackColor = RGB(152, 255, 152) ComboBox1.Activate Else TextBox11.SelText = Replace(TextBox4.Text, "-", "") CreateRecordSet ComboBox1.BackColor = RGB(152, 255, 152) ComboBox1.Activate End If End If Application.Calculate Case 8 'Backspace TextBox4.SelText = "" If TextBox4.SelStart 0 Then _ TextBox4.SelStart = TextBox4.SelStart - 1 TextBox4.SelLength = Len(TextBox4.Text) - TextBox4.SelStart Application.Calculate Case Else 'do nothing End Select Application.Calculate End Sub _________________________________________________ Private Sub TextBox7_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) 'Add functionality to the Enter, Tab and Backspace keys Select Case KeyCode Case 9 'Tab Move Cursor to Competitor Part Number If CBool(Shift And 1) Then ComboBox6.BackColor = RGB(152, 255, 152) ComboBox6.Activate Else TextBox8.BackColor = RGB(152, 255, 152) TextBox8.Activate End If Application.Calculate Case 13 'Enter Move Cursor to Connector Code If CBool(Shift And 1) Then ComboBox6.BackColor = RGB(152, 255, 152) ComboBox6.Activate Else TextBox8.BackColor = RGB(152, 255, 152) TextBox8.Activate End If Application.Calculate Case 8 'Backspace TextBox7.SelText = "" If TextBox7.SelStart 0 Then _ TextBox7.SelStart = TextBox7.SelStart - 1 TextBox7.SelLength = Len(TextBox7.Text) - TextBox7.SelStart Application.Calculate Case Else 'Do nothing End Select Application.Calculate End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
A unexpected behavior | New Users to Excel | |||
Lookup and Indirect unexpected behavior | Excel Discussion (Misc queries) | |||
Unexpected behavior | Excel Discussion (Misc queries) | |||
Cursor Behavior | Setting up and Configuration of Excel | |||
Error or Unexpected Behavior with Office Automation when you use early binding | Excel Programming |