Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
Well, it SOUNDS simple...
Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: Private Sub TextBox2_afterupdate() counter = counter +1 TextBox2.Text = "" TextBox2.SetFocus End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
I don't understand the problem. If you are using the AfterUpdate event,
which occurs by User Interface changes, then the focus should already be on the control. What is it doing/or not doing. Where is the focus after the event? "SMS" wrote in message ... Well, it SOUNDS simple... Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: Private Sub TextBox2_afterupdate() counter = counter +1 TextBox2.Text = "" TextBox2.SetFocus End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
Oh, sorry... the focus goes to the next control in the tab order. On Oct 1, 2:24*pm, "JLGWhiz" wrote: I don't understand the problem. *If you are using the AfterUpdate event, which occurs by User Interface changes, then the focus should already be on the control. *What is it doing/or not doing. *Where is the focus after the event? "SMS" wrote in message ... Well, it SOUNDS simple... Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: *Private Sub TextBox2_afterupdate() * * *counter = counter +1 * * *TextBox2.Text = "" * * *TextBox2.SetFocus *End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much...- Hide quoted text - - Show quoted text - |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
I believe that if the value window of the textbox is empty, the focus
automatircally goes bacward to the next control with a value, and if they are all empty it will go to the first index in tab order. But as soon as you click on the textbox it takes focus. "JLGWhiz" wrote in message ... I don't understand the problem. If you are using the AfterUpdate event, which occurs by User Interface changes, then the focus should already be on the control. What is it doing/or not doing. Where is the focus after the event? "SMS" wrote in message ... Well, it SOUNDS simple... Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: Private Sub TextBox2_afterupdate() counter = counter +1 TextBox2.Text = "" TextBox2.SetFocus End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much... |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
OK, I am a little lost with that...
so what is the method to have the focus retained in the textbox that I am working in? (I never want the focus to leave for any reason other than manually clicking away from it). Thank you... On Oct 1, 3:13*pm, "JLGWhiz" wrote: I believe that if the value window of the textbox is empty, the focus automatircally goes bacward to the next control with a value, and if they are all empty it will go to the first index in tab order. *But as soon as you click on the textbox it takes focus. "JLGWhiz" wrote in message ... I don't understand the problem. *If you are using the AfterUpdate event, which occurs by User Interface changes, then the focus should already be on the control. *What is it doing/or not doing. *Where is the focus after the event? "SMS" wrote in message .... Well, it SOUNDS simple... Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: *Private Sub TextBox2_afterupdate() * * *counter = counter +1 * * *TextBox2.Text = "" * * *TextBox2.SetFocus *End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much...- Hide quoted text - - Show quoted text - |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
OK, I have a "solution". It's stupid, but it works. I am able to set the focus from the textbox afterupdate event code to any other text box, but EXCEPT the one executing the event. the solution is to have TWO text boxes... in the same location. Each one has the same code... but sets the focus to the other one, and at the same time toggling visiblilty of both textboxes. The effect is that it looks like the same text box... but really, we are hopping back and forth between them. Sigh. Excel usually rocks. This, however, has been a real headache. I hope this workaround helps others. On Oct 1, 2:00*pm, SMS wrote: Well, it SOUNDS simple... Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: * Private Sub TextBox2_afterupdate() * * * counter = counter +1 * * * TextBox2.Text = "" * * * TextBox2.SetFocus * End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much... |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple SetFocus on userform issue
Interesting Update!!!!
The problem seems to relate to the existance of a FRAME. If there is a frame object (with tabstop set to true) on the same userform... then it causes things to fail, even in the case of my "workaround" solution. This is some crazy interaction.... is there any rhyme or reason to it? On Oct 1, 3:58*pm, SMS wrote: OK, I have a "solution". *It's stupid, but it works. I am able to set the focus from the textbox afterupdate event code to any other text box, but EXCEPT the one executing the event. the solution is to have TWO text boxes... in the same location. *Each one has the same code... but sets the focus to the other one, and at the same time toggling visiblilty of both textboxes. * *The effect is that it looks like the same text box... but really, we are hopping back and forth between them. Sigh. *Excel usually rocks. *This, however, has been a real headache. I hope this workaround helps others. On Oct 1, 2:00*pm, SMS wrote: Well, it SOUNDS simple... Userform with three controls, TextBox1, TextBox2, TextBox3 For TextBox2 ONLY, I have this code: * Private Sub TextBox2_afterupdate() * * * counter = counter +1 * * * TextBox2.Text = "" * * * TextBox2.SetFocus * End Sub This is supposed to increment a counter, clear the textbox... and here is the ****er: SET THE FOCUS BACK TO TEXTBOX2. This appears to be impossible... I have spent hours on it. Please help! Again, the sole goal here is to get the same text box to have focus when the event is finished. Thank you SO much...- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SetFocus issue | Excel Programming | |||
UserForm Setfocus Problem | Excel Programming | |||
userform setfocus question | Excel Programming | |||
Form, SetFocus and AfterUpdate issue | Excel Programming | |||
Userform setfocus problem | Excel Programming |