Processes in Microsoft 365 for setting up Office apps, redeeming product keys, and activating licenses.
Look at the properties of TextBox100 (and others) and verify that .HideSelection = True. Although this is the default, it might have been set to False at some time and forgotten.
In case that isn't it...
I tried creating a simpler version of this, and the SetFocus did exactly what we expected, moving the cursor to TextBox503 and not leaving anything highlighted in TextBox100.
My RouteAssignment has three textboxes (TextBox1, TextBox 100, and TextBox503) and a command button. My OtherChoices has just a command button. The code in RouteAssignment is this:
Private Sub btnOK_Click()
Unload Me
End Sub
Private Sub TextBox100_Enter()
OtherChoices.Show
TextBox503.SetFocus
End Sub
and the code in OtherChoices is this:
Private Sub btnOK_Click()
RouteAssignment.TextBox100.Value = "foobar"
Unload Me
End Sub
Running RouteAssignment, the cursor starts in TextBox1 and I tab to enter TextBox100. OtherChoices pops up, and I click its command button. The result is text in TextBox100 that is not selected or
highlighted, and the cursor in TextBox 503.
Maybe you can try a similar simplified setup to see whether it behaves the same for you; if so, add the other bits one at a time until you either find the culprit or complete a working copy.
On Wed, 18 Aug 2010 01:16:54 +0000, Ordnance1 wrote:
Thank you, Sorry I was not more clear. I had tried what you suggested but the text in TextBox100 remained selected. Let me share both sets of code involved:
'This code is contained within the RouteAssignment UserForm
Private Sub TextBox100_Enter()
Assignment1 = True
OtherChoices.Show
TextBox503.SetFocus
End Sub
----------------------------------------------------------------------------------------------------------------4---
'This code is contained within the OtherChoices UserForm
Private Sub ListBox2_Click()
If Assignment1 = True Then
With Me.ListBox2
If .ListIndex < 0 Then
'nothing selected, same as cancel?
Else
'Sets the Exempt from coverage status route
RouteAssignment.TextBox100.Value = .List(.ListIndex, 0)
Exempt1 = .List(.ListIndex, 13) 'Exempt from coverage status route 1
If Exempt1 = "Yes" Then
RouteAssignment.OptionButton103.Value = True
RouteAssignment.OptionButton103.ForeColor = &HFF&
RouteAssignment.OptionButton104.Value = False
End If
If Exempt1 = "No" Then
RouteAssignment.OptionButton104.Value = True
RouteAssignment.OptionButton103.ForeColor = &H80000008
RouteAssignment.OptionButton103.Value = False
End If
End If
End With
End If
Unload Me
End Sub
"Jay Freedman [MVP]" wrote in message news:*** Email address is removed for privacy ***...
You never "remove focus" from anything. You just set the focus where you want it (which you didn't say). For example, if you want the focus to be in TextBox101, add the line
TextBox101.SetFocus
Jay Freedman
MS Word MVP FAQ: http://word.mvps.org