![]() |
TextBox focus 4
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
TextBox focus 4
How about this:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 13 Then MsgBox "doing processing here" TextBox1.SetFocus KeyCode = 0 End If End Sub RBS "Tim Coddington" wrote in message ... I have a userform with two option buttons and a textbox. I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
TextBox focus 4
Thanks. This appears to work. Will test it totally on Monday.
What does the 'KeyCode = 0' statement do? "RB Smissaert" wrote in message ... How about this: Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 13 Then MsgBox "doing processing here" TextBox1.SetFocus KeyCode = 0 End If End Sub RBS "Tim Coddington" wrote in message ... I have a userform with two option buttons and a textbox. I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
TextBox focus 4
Tim,
Use the change event Private Sub OptionButton1_Change() TextBox1.SetFocus End Sub Private Sub OptionButton2_Change() TextBox1.SetFocus End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Tim Coddington" wrote in message ... I have a userform with two option buttons and a textbox. I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
TextBox focus 4
It just resets the Keycode to zero.
So the normal result of the enter key won't happen. Actually you don't need to set the focus as you are already in the textbox. So this will do the same: Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 13 Then MsgBox "doing processing here" KeyCode = 0 End If End Sub RBS "Tim Coddington" wrote in message ... Thanks. This appears to work. Will test it totally on Monday. What does the 'KeyCode = 0' statement do? "RB Smissaert" wrote in message ... How about this: Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 13 Then MsgBox "doing processing here" TextBox1.SetFocus KeyCode = 0 End If End Sub RBS "Tim Coddington" wrote in message ... I have a userform with two option buttons and a textbox. I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
TextBox focus 4
_Change() isn't fired after <cr in a text box.
Tried it in _Enter(), but then, you can't change the option buttons. I'll try RB Smissaert's solution Monday, but am aprehesive about its ability to work.. "Bob Phillips" wrote in message ... Tim, Use the change event Private Sub OptionButton1_Change() TextBox1.SetFocus End Sub Private Sub OptionButton2_Change() TextBox1.SetFocus End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Tim Coddington" wrote in message ... I have a userform with two option buttons and a textbox. I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
TextBox focus 4 - Thanks for all your help. I think I've got it now.
Thanks for all your help. I think I've got it now.
"RB Smissaert" wrote in message ... It just resets the Keycode to zero. So the normal result of the enter key won't happen. Actually you don't need to set the focus as you are already in the textbox. So this will do the same: Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 13 Then MsgBox "doing processing here" KeyCode = 0 End If End Sub RBS "Tim Coddington" wrote in message ... Thanks. This appears to work. Will test it totally on Monday. What does the 'KeyCode = 0' statement do? "RB Smissaert" wrote in message ... How about this: Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) If KeyCode = 13 Then MsgBox "doing processing here" TextBox1.SetFocus KeyCode = 0 End If End Sub RBS "Tim Coddington" wrote in message ... I have a userform with two option buttons and a textbox. I want the text box to always have focus (except I need to be able to select the check boxes) so a user can input one string, press 'Enter' to process, and enter the next string repeatedly. Here is the total amount of code ... Private Sub OptionButton1_Click() TextBox1.SetFocus End Sub Private Sub OptionButton2_Click() TextBox1.SetFocus End Sub Every time I type something into the text box and press 'Enter', the cursor disappears from the text box and I have to click on it (or one of the option buttons) to get it back. Can someone tell me what is happening and how to solve it?? PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE???? |
All times are GMT +1. The time now is 04:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com