Please help me before i Get MAD SetFocus doesn't work

A

althafexcel

Im working on MS Word 2003. I have created two VB Text box controls
namely A & B.

Once when the user inputs a character in field A, the focus must move
to the field B. How can this be acheived.

Actually i have done the code which doesn't work and it gives error in
the setFocus line.

Private Sub TextBox1_Change()

If len(A.text)>0 then
B.setFocus
end if

End Sub

It gives object doesn't support this method in the line of B.SetFocus.
Please help me before i get mad.
 
G

Greg Maxey

Im working on MS Word 2003. I have created two VB Text box controls
namely A & B.

Once when the user inputs a character in field A, the focus must move
to the field B. How can this be acheived.

Actually i have done the code which doesn't work and it gives error in
the setFocus line.

Private Sub TextBox1_Change()

If len(A.text)>0 then
B.setFocus
end if

End Sub

It gives object doesn't support this method in the line of B.SetFocus.
Please help me before i get mad.

I hope you have contained your temper long enough to see this
response.

It seems to me that if you have a Textbox "A" then your code should
be:

Private Sub A_Change()
If Len(A.Text) > 0 Then
B.SetFocus
End If
End Sub
 
P

Perry

If the main purpose is to let users input a one lettre value, why do you use
a textbox?
Think about that first...
If you use a textbox, users will be tempted to input more text ...

I would guide the user in such case, by using a Combobox instead ...
Populate this Combo with the alfabet, so users see a one character input
being required there.

Other advantage and this covers yr need, it's easy to program, like in:
(Combobox1 and Textbox1 available on a plain userform)

Private sub userform_initialize()
Me.combobox1.list = Array("a", "b", "c")
End sub

private sub Combobox1_change()
Me.Textbox1.Setfocus
End sub

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 

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