Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A unexpected behavior Marsh New Users to Excel 9 January 15th 09 06:23 PM
Lookup and Indirect unexpected behavior Lori Excel Discussion (Misc queries) 6 February 11th 07 11:05 AM
Unexpected behavior ceshelman Excel Discussion (Misc queries) 0 July 27th 05 06:58 PM
Cursor Behavior Mark P Setting up and Configuration of Excel 1 March 1st 05 01:21 PM
Error or Unexpected Behavior with Office Automation when you use early binding Barb[_5_] Excel Programming 3 September 15th 04 03:17 PM


All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"