Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SMS SMS is offline
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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   Report Post  
Posted to microsoft.public.excel.programming
SMS SMS is offline
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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   Report Post  
Posted to microsoft.public.excel.programming
SMS SMS is offline
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
SMS SMS is offline
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
SMS SMS is offline
external usenet poster
 
Posts: 15
Default 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
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
SetFocus issue JT Excel Programming 0 April 13th 09 05:12 PM
UserForm Setfocus Problem BOBODD Excel Programming 2 November 29th 06 01:43 AM
userform setfocus question Gary Keramidas Excel Programming 3 November 27th 06 09:20 PM
Form, SetFocus and AfterUpdate issue Piers 2k Excel Programming 2 November 8th 05 01:52 PM
Userform setfocus problem Martin Hibberd[_2_] Excel Programming 1 November 10th 04 12:12 PM


All times are GMT +1. The time now is 12:23 AM.

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"