![]() |
Think I may have screwed myself...
mmm... now I've done it.
I made a keyboard, on-screen, for a touchscreen in a userform. Works great! It adds characters one at a time into a specific textbox. Oops.... Now I need to add a few more text boxes... and I want it to go into the text box with the current focus... problem is, which text box has the current focus? Because as soon as I press the keyboard keys (Label objects) it is *they* that have the current focus! Think I'm in a spot of trouble here :) Any ideas very much appreciated.... SMS |
Think I may have screwed myself...
Hello,
Userform has a property named ActiveControl. HTH sjoo. "rci" wrote: mmm... now I've done it. I made a keyboard, on-screen, for a touchscreen in a userform. Works great! It adds characters one at a time into a specific textbox. Oops.... Now I need to add a few more text boxes... and I want it to go into the text box with the current focus... problem is, which text box has the current focus? Because as soon as I press the keyboard keys (Label objects) it is *they* that have the current focus! Think I'm in a spot of trouble here :) Any ideas very much appreciated.... SMS |
Think I may have screwed myself...
Labels cannot take focus. With this, focus always remains on the text box.
Private Sub Label1_Click() TextBox1.Text = TextBox1.Text & "A" End Sub Do you mean "ActiveControl" ? NickHK "rci" wrote in message ... mmm... now I've done it. I made a keyboard, on-screen, for a touchscreen in a userform. Works great! It adds characters one at a time into a specific textbox. Oops.... Now I need to add a few more text boxes... and I want it to go into the text box with the current focus... problem is, which text box has the current focus? Because as soon as I press the keyboard keys (Label objects) it is *they* that have the current focus! Think I'm in a spot of trouble here :) Any ideas very much appreciated.... SMS |
Think I may have screwed myself...
Thx Nick, Well, that is good news... so, how do I find what text box (if any) has the current focus, and then, having that identified in a variable, how do I use that variable to enter text into the text box? Seems it would have to go like this: (psydocode) CurrentTextBox = Me.HasFocus CurrentTextox.value = CurrentTextBox.value & NewKeyPressed Looks simple enough... how come I doubt it is :-) Thx! NickHK wrote: : Labels cannot take focus. With this, focus always remains on the text box. : Private Sub Label1_Click() : TextBox1.Text = TextBox1.Text & "A" : End Sub : Do you mean "ActiveControl" ? : NickHK : "rci" wrote in message : ... : mmm... now I've done it. : : I made a keyboard, on-screen, for a touchscreen in a userform. Works : great! : It adds characters one at a time into a specific textbox. : : Oops.... : : Now I need to add a few more text boxes... and I want it to go into the : text : box with the current focus... problem is, which text box has the current : focus? Because as soon as I press the keyboard keys (Label objects) it is : *they* that have the current focus! : : Think I'm in a spot of trouble here :) : : Any ideas very much appreciated.... : : SMS |
Think I may have screwed myself...
The form has an Activecontrol property.
Private Sub Label1_Click() ActiveControl.Text = ActiveControl.Text & " A" End Sub Depending on your form/needs, you should check what the ActiveControl is. If TypeOf ActiveControl Is MSForms.TextBox Then .. NickHK "rci" wrote in message ... Thx Nick, Well, that is good news... so, how do I find what text box (if any) has the current focus, and then, having that identified in a variable, how do I use that variable to enter text into the text box? Seems it would have to go like this: (psydocode) CurrentTextBox = Me.HasFocus CurrentTextox.value = CurrentTextBox.value & NewKeyPressed Looks simple enough... how come I doubt it is :-) Thx! NickHK wrote: : Labels cannot take focus. With this, focus always remains on the text box. : Private Sub Label1_Click() : TextBox1.Text = TextBox1.Text & "A" : End Sub : Do you mean "ActiveControl" ? : NickHK : "rci" wrote in message : ... : mmm... now I've done it. : : I made a keyboard, on-screen, for a touchscreen in a userform. Works : great! : It adds characters one at a time into a specific textbox. : : Oops.... : : Now I need to add a few more text boxes... and I want it to go into the : text : box with the current focus... problem is, which text box has the current : focus? Because as soon as I press the keyboard keys (Label objects) it is : *they* that have the current focus! : : Think I'm in a spot of trouble here :) : : Any ideas very much appreciated.... : : SMS |
All times are GMT +1. The time now is 09:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com