Focus In Modeless Form (spare me the grief)

Joined
Jul 10, 2005
Messages
4
Reaction score
0
I hope someone out there can help me.
I have a modeless Form. It has 1 label and one textbox.
on exit of the textbox(by user hitting enter) It looses it focus to Excel. However When I give focus back to the userform by AppActivate(userform1.caption) Textbox1 has the focus, However there is no cursor indication and I can not overwrite what is currently in the field, it only appears to allow me to backspace over the previous entry. Here is the code I am using :

Module 1 -- code:
Sub ShowUserForm()
If UserForm1.Visible = True Then
AppActivate (UserForm1.Caption)
Else
UserForm1.Show (vbModeless)
End If
End Sub

UserForm1 -- code:
Private Sub TextBox1_Enter()
Me.TextBox1.BackColor = &HFFFF&
End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True
Me.TextBox1.BackColor = &H80000005
AppActivate ("Microsoft excel")
End Sub

Private Sub UserForm_Activate()
Me.TextBox1.SetFocus
End Sub

*** note Ive had a little bit of success with the userform_click event and adding a second text box, But I dont want the user to click on the body of the userform to set the focus.

PLEASE PLEASE HELP!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top