Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Enter pressed in Textbox

How do I signal my code to run when the user presses the
ENTER button in the Text Box TextBoxCustNum?

Private Sub TextBoxCustNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
?????????????????????????????
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Enter pressed in Textbox

Hi embarrased,

You need to use the KeyDown event for that, as the Enter key will never
trigger the KeyPress event:

Private Sub TextBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
'/ ENTER key pressed
MsgBox "Done"
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


embarrased wrote:
How do I signal my code to run when the user presses the
ENTER button in the Text Box TextBoxCustNum?

Private Sub TextBoxCustNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
?????????????????????????????
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Enter pressed in Textbox

Private Sub TextBoxCustNum_Exit(ByVal Cancel As MSForms.ReturnBoolean)

End Sub

is the event you want


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"embarrased" wrote in message
...
How do I signal my code to run when the user presses the
ENTER button in the Text Box TextBoxCustNum?

Private Sub TextBoxCustNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
?????????????????????????????
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Enter pressed in Textbox

i would use:


Private Sub textbox1_enter()
Application.Run "PATH!MACRO_NAME"
end sub

-----Original Message-----
How do I signal my code to run when the user presses the
ENTER button in the Text Box TextBoxCustNum?

Private Sub TextBoxCustNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
?????????????????????????????
End Sub

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Enter pressed in Textbox

Thanks Guys!

I couldn't get a msgbox to return the Value of
the 'Enter' Key; I guess it was because I was using the
KeyPress Event instead of the KeyDown Event. Dangit!

It's amazing how the stupid things sometimes stump me.
Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Enter pressed in Textbox

Hi Jake,

Thanks for the post and I applied your code to my
project. However, I now receive a fatal error and Excel
must close. My error handling notwithstanding, why would
the code execute when I trigger the button event with my
mouse, but not when I hit enter in the text box?

Here's the code for both events:

Private Sub CommandButtonExecute_Click()
RunWorksheet
End Sub

Private Sub TextBoxCustNum_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)

MsgBox KeyCode
If KeyCode = 13 Then ' ENTER key pressed
RunWorksheet
End If
End Sub

Thanks in advance.

-----Original Message-----
Hi embarrased,

You need to use the KeyDown event for that, as the Enter

key will never
trigger the KeyPress event:

Private Sub TextBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
'/ ENTER key pressed
MsgBox "Done"
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


embarrased wrote:
How do I signal my code to run when the user presses

the
ENTER button in the Text Box TextBoxCustNum?

Private Sub TextBoxCustNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
?????????????????????????????
End Sub


.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Enter pressed in Textbox

Hi,

I don't know; I haven't seen that one before. If you'd like, you can email
the workbook directly to me at mvp<atlonghead[dot]com, and I'll see what I
can do.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


embarrassed wrote:
Hi Jake,

Thanks for the post and I applied your code to my
project. However, I now receive a fatal error and Excel
must close. My error handling notwithstanding, why would
the code execute when I trigger the button event with my
mouse, but not when I hit enter in the text box?

Here's the code for both events:

Private Sub CommandButtonExecute_Click()
RunWorksheet
End Sub

Private Sub TextBoxCustNum_KeyDown(ByVal KeyCode As
MSForms.ReturnInteger, ByVal Shift As Integer)

MsgBox KeyCode
If KeyCode = 13 Then ' ENTER key pressed
RunWorksheet
End If
End Sub

Thanks in advance.

-----Original Message-----
Hi embarrased,

You need to use the KeyDown event for that, as the Enter key will
never trigger the KeyPress event:

Private Sub TextBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
'/ ENTER key pressed
MsgBox "Done"
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


embarrased wrote:
How do I signal my code to run when the user presses the
ENTER button in the Text Box TextBoxCustNum?

Private Sub TextBoxCustNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
?????????????????????????????
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
When enter key is pressed, cursor does not move to next cell in Ex Blackie Excel Discussion (Misc queries) 3 April 19th 23 02:10 PM
how do I change which cell becomes active when enter is pressed? scotpiper Excel Discussion (Misc queries) 1 April 7th 09 12:18 AM
Excel2007 Stipulate where cursor goes when Enter Key pressed RonG Excel Discussion (Misc queries) 5 March 9th 09 09:59 PM
Moving between cells when enter is pressed woalmoore Excel Discussion (Misc queries) 3 July 18th 08 04:24 PM
Enter button jumps to next cell each time its pressed!!!! evasmagacz Excel Discussion (Misc queries) 3 June 17th 07 08:37 PM


All times are GMT +1. The time now is 11:17 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"