Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default "Enter" event for text box control?

Hi All

I have a text box control from the control toolbox (not a Form's
control) in which I want my user to enter some data. I would like to
know when they hit "Enter" when they are done.

However the TextBox control does not seem to have an event that will
capture the "Enter" as the Help file for the KeyPress event states:
A KeyPress event does not occur under the following conditions:
Pressing TAB.
Pressing ENTER.

I dont see any other event that will tell me when the user hits
enter.

Of course, I could stick a command button next to the text box that
says "OK" but I would prefer, if possible, to capture the "Enter" and
go.

Is anyone aware of a way for me to capture the "Enter"?

Thanks in advance for any ideas.
Chrisso

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default "Enter" event for text box control?

Use the KeyDown event instead.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Chrisso" wrote in message
oups.com...
Hi All

I have a text box control from the control toolbox (not a Form's
control) in which I want my user to enter some data. I would like to
know when they hit "Enter" when they are done.

However the TextBox control does not seem to have an event that will
capture the "Enter" as the Help file for the KeyPress event states:
A KeyPress event does not occur under the following conditions:
Pressing TAB.
Pressing ENTER.

I dont see any other event that will tell me when the user hits
enter.

Of course, I could stick a command button next to the text box that
says "OK" but I would prefer, if possible, to capture the "Enter" and
go.

Is anyone aware of a way for me to capture the "Enter"?

Thanks in advance for any ideas.
Chrisso



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default "Enter" event for text box control?

Hi Chrisso,

As Bob suggests, the KeyDown event will detect an enter press
KeyCode = vbKeyReturn

However, does user press Enter when done or merely select something else.
Perhaps the LostFocus event would help.

Regards,
Peter T

"Chrisso" wrote in message
oups.com...
Hi All

I have a text box control from the control toolbox (not a Form's
control) in which I want my user to enter some data. I would like to
know when they hit "Enter" when they are done.

However the TextBox control does not seem to have an event that will
capture the "Enter" as the Help file for the KeyPress event states:
A KeyPress event does not occur under the following conditions:
Pressing TAB.
Pressing ENTER.

I dont see any other event that will tell me when the user hits
enter.

Of course, I could stick a command button next to the text box that
says "OK" but I would prefer, if possible, to capture the "Enter" and
go.

Is anyone aware of a way for me to capture the "Enter"?

Thanks in advance for any ideas.
Chrisso



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default "Enter" event for text box control?

Hi Guys - thanks for your respones.

Bob - I am using an ActiveX control as I need the "PasswordChar"
property as what the user enters is a password required to initiate
some logic. When I try to add the KeyDown event to its code VB
complains and I think this is because the events list must be
different between ActiveX text boxes and Forms text boxes. How can I
get a list of ActiveX text box events? The Excel help facility only
seems to list events for Form text boxes.

Peter - As this is a "password" text box the user just hits enter and
does not select anything else so LostFocus wont help me on this one I
think.

So - to clarify my original question: How do I capture an "Enter" on
an ActiveX text box.

I am assuming that when you select through Excel:
View-Toolbars-Control Toolbox
the controls you see are ActiveX controls - I could be wrong!

Cheers
Chrisso

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default "Enter" event for text box control?

If user knows to hit enter after the entering the password -

Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Const PASSWORD = "cesame"

If KeyCode = vbKeyReturn Then
If LCase(TextBox1.Text) = PASSWORD Then
MsgBox "Password valid"
End If
End If
End Sub

Alternatively, simply -

Private Sub TextBox1_Change()
Const PASSWORD = "cesame"

If LCase(TextBox1.Text) = PASSWORD Then
MsgBox "Password valid"
End If

End Sub

I am assuming that when you select through Excel:
View-Toolbars-Control Toolbox
the controls you see are ActiveX controls - I could be wrong!


Indeed they are ActiveX controls.

Regards,
Peter T

"Chrisso" wrote in message
oups.com...
Hi Guys - thanks for your respones.

Bob - I am using an ActiveX control as I need the "PasswordChar"
property as what the user enters is a password required to initiate
some logic. When I try to add the KeyDown event to its code VB
complains and I think this is because the events list must be
different between ActiveX text boxes and Forms text boxes. How can I
get a list of ActiveX text box events? The Excel help facility only
seems to list events for Form text boxes.

Peter - As this is a "password" text box the user just hits enter and
does not select anything else so LostFocus wont help me on this one I
think.

So - to clarify my original question: How do I capture an "Enter" on
an ActiveX text box.

I am assuming that when you select through Excel:
View-Toolbars-Control Toolbox
the controls you see are ActiveX controls - I could be wrong!

Cheers
Chrisso





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default "Enter" event for text box control?

I don't get that problem Chrisso (there isn't a forms toolbbar textbox).

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Chrisso" wrote in message
oups.com...
Hi Guys - thanks for your respones.

Bob - I am using an ActiveX control as I need the "PasswordChar"
property as what the user enters is a password required to initiate
some logic. When I try to add the KeyDown event to its code VB
complains and I think this is because the events list must be
different between ActiveX text boxes and Forms text boxes. How can I
get a list of ActiveX text box events? The Excel help facility only
seems to list events for Form text boxes.

Peter - As this is a "password" text box the user just hits enter and
does not select anything else so LostFocus wont help me on this one I
think.

So - to clarify my original question: How do I capture an "Enter" on
an ActiveX text box.

I am assuming that when you select through Excel:
View-Toolbars-Control Toolbox
the controls you see are ActiveX controls - I could be wrong!

Cheers
Chrisso



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
Is there a special character for "ALT+ENTER" for text formulae? Bill sailing[_2_] Excel Discussion (Misc queries) 2 March 5th 08 09:52 PM
Code event for the "enter Key" Steved Excel Programming 5 May 31st 07 09:00 PM
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! [email protected] Excel Discussion (Misc queries) 3 January 5th 07 02:18 PM
Scroll Bar missing "Control" tab in "Format Properties" dialog box Peter Rooney Excel Discussion (Misc queries) 5 August 24th 06 05:36 PM
"enter" event of activex combobox? crapit Excel Programming 11 July 13th 04 11:59 AM


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