Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 563
- Office Version
- 365
- 2010
- Platform
- Windows
On my form I have six text boxes and a submit button and a cancel button. When the form initializes all text boxes and buttons are disabled except for the first text box and the cancel button. Once the user enters a value in the first textbox and the length is greater than 4 characters then the second textbox is enabled and so on. This will ensure that no textboxes get missed. Once the last textbox contains a set amount of characters the submit buttons is then enabled. The problem that I am having with the code below is that when the user re-enters the txtbxCnt textbox it will clear the contents as expected but jump down to the cancel button. I need the focus to stay inside txtbxCnt textbox. Inside the Private Sub txtbxCnt_Enter() I even tried setting the focus there but that didn't work either.
Thank You
Code:
Private Sub txtbxCnt_Enter()
If Len(Me.txtbxCnt.Value) > 0 And IsNumeric(Me.txtbxCnt.Value) Then
Me.txtbxCnt.Value = Me.txtbxCnt.Value & "ct"
Else
Me.txtbxCnt.Value = ""
Me.txtbxCnt.SetFocus
End If
End Sub
VBA Code:
Private Sub txtbxCnt_Change()
If Len(Me.txtbxCnt.Value) > 0 Then
Me.txtbxMgAmt.Enabled = True
Else
Me.txtbxMgAmt.Enabled = False
End If
End Sub
Private Sub txtbxCnt_Enter()
If Len(Me.txtbxCnt.Value) > 0 And IsNumeric(Me.txtbxCnt.Value) Then
Me.txtbxCnt.Value = Me.txtbxCnt.Value & "ct"
Else
Me.txtbxCnt.Value = ""
End If
End Sub
Private Sub txtbxCnt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(Me.txtbxCnt.Value) > 0 And IsNumeric(Me.txtbxCnt.Value) Then
Me.txtbxCnt.Value = Me.txtbxCnt.Value & "ct"
Else
Me.txtbxCnt.Value = ""
End If
End Sub
Thank You