Excel 2010
Win 8 Pro
Greetings to all,
I am including some stripped-down, simplified code that illustrates a problem that I'm having with a form. This little form contains only a checkbox and 3 textboxes, with the checkbox having TabIndex 0, and the first, second and third textboxes having TabIndexes of 1,2,and 3, respectively. Here's what I want the form to do...
1) form initialization enables ONLY the checkbox; all 3 textboxes are DISabled.
2) once the checkbox is checked, the first textbox is enabled and given the focus.
3) once data is input into the first textbox and [Enter] (or [Tab]) is pressed, the second textbox is enabled and given the focus.
4) once data is input into the second textbox and [Enter] (or [Tab]) is pressed, the third textbox is enabled and given the focus.
Everything's fine until step 3: the first time [Enter] is pressed the data in the first textbox gets highlighted (why?), and then only after [Enter] is pressed a second time does the focus move to the second textbox.
Further, after data is entered into the second textbox and [Enter] is pressed, the data in the first textbox gets highlighted (why?); after [Enter] is pressed a second time the focus then moves back to the second textbox, and only after entering [Enter] a third time does the cursor finally move to the third textbox.
I'm obviously missing something here in my understanding of form events. Would someone please point me in the right direction?
THANKS!
-------------------------------------------------------------------
Win 8 Pro
Greetings to all,
I am including some stripped-down, simplified code that illustrates a problem that I'm having with a form. This little form contains only a checkbox and 3 textboxes, with the checkbox having TabIndex 0, and the first, second and third textboxes having TabIndexes of 1,2,and 3, respectively. Here's what I want the form to do...
1) form initialization enables ONLY the checkbox; all 3 textboxes are DISabled.
2) once the checkbox is checked, the first textbox is enabled and given the focus.
3) once data is input into the first textbox and [Enter] (or [Tab]) is pressed, the second textbox is enabled and given the focus.
4) once data is input into the second textbox and [Enter] (or [Tab]) is pressed, the third textbox is enabled and given the focus.
Everything's fine until step 3: the first time [Enter] is pressed the data in the first textbox gets highlighted (why?), and then only after [Enter] is pressed a second time does the focus move to the second textbox.
Further, after data is entered into the second textbox and [Enter] is pressed, the data in the first textbox gets highlighted (why?); after [Enter] is pressed a second time the focus then moves back to the second textbox, and only after entering [Enter] a third time does the cursor finally move to the third textbox.
I'm obviously missing something here in my understanding of form events. Would someone please point me in the right direction?
THANKS!
-------------------------------------------------------------------
Code:
Private Sub UserForm_Initialize()
Me.chkCheckBox.Enabled = True
Me.txtBox1.Enabled = False
Me.txtBox2.Enabled = False
Me.txtBox3.Enabled = False
End Sub
Private Sub chkCheckBox_Click()
Me.txtBox1.Enabled = True
Me.txtBox1.SetFocus
End Sub
Private Sub txtBox1_AfterUpdate()
Me.txtBox2.Enabled = True
Me.txtBox2.SetFocus
End Sub
Private Sub txtBox2_AfterUpdate()
Me.txtBox3.Enabled = True
Me.txtBox3.SetFocus
End Sub
Last edited by a moderator: