How to SetFocus on Built-in Control

  • Thread starter Thread starter Michael Hyatt
  • Start date Start date
M

Michael Hyatt

I have a custom e-mail message form. When the user tabs out of the "To"
field, I want to parse the recipient name and insert the first name into the
body control. All of this is working fine. I am using the Item_Property
change event. However, when the user tabs out of the To field, the cursor
does not advance to the CC field as expected. Why?

I have tried to SetFocus on the CC control, but that doesn't work. How can I
do this? Here's what I have so far:

Sub Item_PropertyChange(ByVal Name)

If Name = "To" Then
StrTo = Item.To
iLength = Len(strTo)
iStart = InStr(1, strTo, ", ", vbTextCompare)

If iStart = 0 Then ' In standard format of FirstName LastName
iSpace = InStr(1, strTo, " ", vbTextCompare)
strFirstName = Left(strTo, iSpace - 1)
Else ' In reverse format of LastName, FirstName
StrFirstName = Mid(strTo, iStart + 2, iLength - iStart)
End If

strFirstName = "<Strong>" & strFirstName & "," & "</Strong>"
Item.htmlbody = strFirstName & Item.HTMLBody
End If

' Need to set the focus on the CC textbox control

End Sub
 
If the user isn't tabbing from the To to the Cc field, check the tab order
for the page.
 
Back
Top