Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default UserForm Textbox.setfocus help

The following code is not consistent; The focus is set ONLY the FIRST TIME I
activate the Worksheet - If I lease WS (Deactivate - UserForm1.hide) and
return to WS (Below) my textbox1 DOES NOT GET THE FOCUS.. What am I missing?

Private Sub Worksheet_Activate()
With UserForm1
.TextBox1.Value = ""
.TextBox2.Value = ""
.TextBox3.Value = ""
.Show vbModeless
.TextBox1.SetFocus ' This line not being consistent
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default UserForm Textbox.setfocus help

If you hide the form, it is still active. So when you unhide it the Activate
event is not triggered and your macro does not run. To remedy this, add a
line after your unhide command line to again set focus.

UserForm1.Show
UserForm1.TextBox1.SetFocus


"JMay" wrote:

The following code is not consistent; The focus is set ONLY the FIRST TIME I
activate the Worksheet - If I lease WS (Deactivate - UserForm1.hide) and
return to WS (Below) my textbox1 DOES NOT GET THE FOCUS.. What am I missing?

Private Sub Worksheet_Activate()
With UserForm1
.TextBox1.Value = ""
.TextBox2.Value = ""
.TextBox3.Value = ""
.Show vbModeless
.TextBox1.SetFocus ' This line not being consistent
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default UserForm Textbox.setfocus help

I misread your post, disregard my previous suggestion.

"JMay" wrote:

The following code is not consistent; The focus is set ONLY the FIRST TIME I
activate the Worksheet - If I lease WS (Deactivate - UserForm1.hide) and
return to WS (Below) my textbox1 DOES NOT GET THE FOCUS.. What am I missing?

Private Sub Worksheet_Activate()
With UserForm1
.TextBox1.Value = ""
.TextBox2.Value = ""
.TextBox3.Value = ""
.Show vbModeless
.TextBox1.SetFocus ' This line not being consistent
End With
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default UserForm Textbox.setfocus help

After some experimenting, it looks like the problem is in the Show.Modeless
command. It seems that when it shows modeless that there is no focus set
until the form is clicked. However, when it is shown modal, the default
focus goes to the first control in the pecking order on the form.
Apparently, this is a design characteristic.

"JMay" wrote:

The following code is not consistent; The focus is set ONLY the FIRST TIME I
activate the Worksheet - If I lease WS (Deactivate - UserForm1.hide) and
return to WS (Below) my textbox1 DOES NOT GET THE FOCUS.. What am I missing?

Private Sub Worksheet_Activate()
With UserForm1
.TextBox1.Value = ""
.TextBox2.Value = ""
.TextBox3.Value = ""
.Show vbModeless
.TextBox1.SetFocus ' This line not being consistent
End With
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default UserForm Textbox.setfocus help

Thanks JLG;
So I could leave the Userform Modeless
I added a Close UserForm Button (which Hides it only)
When I reactivate my Sheet (with the UF) the
Textbox1 gets focus (EVERY TIME).

Thanks for hanging in there and providing the help..

Jim


"JLGWhiz" wrote:

After some experimenting, it looks like the problem is in the Show.Modeless
command. It seems that when it shows modeless that there is no focus set
until the form is clicked. However, when it is shown modal, the default
focus goes to the first control in the pecking order on the form.
Apparently, this is a design characteristic.

"JMay" wrote:

The following code is not consistent; The focus is set ONLY the FIRST TIME I
activate the Worksheet - If I lease WS (Deactivate - UserForm1.hide) and
return to WS (Below) my textbox1 DOES NOT GET THE FOCUS.. What am I missing?

Private Sub Worksheet_Activate()
With UserForm1
.TextBox1.Value = ""
.TextBox2.Value = ""
.TextBox3.Value = ""
.Show vbModeless
.TextBox1.SetFocus ' This line not being consistent
End With
End Sub

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
How do you SETFOCUS on TextBox Mike[_113_] Excel Programming 3 December 11th 06 02:00 AM
Having problems with textbox setfocus Terry K Excel Programming 1 May 9th 06 02:23 PM
setfocus in textbox on multipage Martin Excel Programming 5 January 6th 06 04:20 AM
SetFocus to first textbox on userform upon Userform1.Show Paul Simon[_3_] Excel Programming 6 February 11th 04 04:31 PM
TextBox.SetFocus steve Excel Programming 4 July 16th 03 07:40 PM


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