A
abxy
Hi,
ok, i'm having big problem. I'm creating a userform where the instea
of the user pressing a command button to do an opertation after they'v
put something in a textbox, all they have to do is press enter on th
keyboard and the operation will be carried out.
in the code i have attached to pressing the enter key, i have it s
that the textbox is cleared and becomes the focus again. However, i
seems that the userform is also using the 'enter' key like it normall
does as well because after performing the code attached to th
pressing the key, it will tab to the next item on the userform as if
pressed enter instead of the textbox becoming focus again like i want.
To see what was going on, i changed the code so that 'g' instead o
'enter' performed the code. when i press 'g' It carried out the cod
and the textbox was cleared and became the focus, but then the letter
was in the textbox.
It seems like the code is doing what i want, but it also presses th
key afterwards, any idea on how to fix that?
here's the basic code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer)
'MsgBox KeyCode
If KeyCode = 13 Then
TextBox1.Value = ""
TextBox1.setfocus
End If
End Su
ok, i'm having big problem. I'm creating a userform where the instea
of the user pressing a command button to do an opertation after they'v
put something in a textbox, all they have to do is press enter on th
keyboard and the operation will be carried out.
in the code i have attached to pressing the enter key, i have it s
that the textbox is cleared and becomes the focus again. However, i
seems that the userform is also using the 'enter' key like it normall
does as well because after performing the code attached to th
pressing the key, it will tab to the next item on the userform as if
pressed enter instead of the textbox becoming focus again like i want.
To see what was going on, i changed the code so that 'g' instead o
'enter' performed the code. when i press 'g' It carried out the cod
and the textbox was cleared and became the focus, but then the letter
was in the textbox.
It seems like the code is doing what i want, but it also presses th
key afterwards, any idea on how to fix that?
here's the basic code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer)
'MsgBox KeyCode
If KeyCode = 13 Then
TextBox1.Value = ""
TextBox1.setfocus
End If
End Su