Question on fields when creating a form

G

Guest

I have created a form where the user must input a single number into a field.
This number is one of seventeen characters comprising a VIN number. When the
user enters this number, I want the cursor to jump to the next field without
the user having to TAB. The field width is set to one (1) character width.
How can I do this?
Thanks,
Dan
 
J

Jay Freedman

Dan said:
I have created a form where the user must input a single number into
a field. This number is one of seventeen characters comprising a VIN
number. When the user enters this number, I want the cursor to jump
to the next field without the user having to TAB. The field width is
set to one (1) character width. How can I do this?
Thanks,
Dan

There's no way to accomplish that with the form field from the Forms
toolbar. You need the functionality of a Userform (a macro-driven custom
dialog). See http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm to get
started.

When you have text fields in a Userform, you can write an "event handler" in
the Userform's code that runs each time something is typed in the text
field, like this:

Private Sub TextBox1_Change()
If Len(TextBox1.Text) >= 1 Then
TextBox2.SetFocus
End If
End Sub

This says that if the field TextBox1 isn't empty, the cursor (focus) get set
to the next field, TextBox2. Similar code can be written for TextBox2, and
so on. (Also, it's a good idea to change the names of the fields from the
default TextBoxN to something meaningful.)

When all the text fields are properly filled (and the Userform can also
validate the number according to whatever rules apply to a VIN), the user
clicks the OK button. The code for the OK button transfers the characters
from the fields on the Userform into bookmarks in the document.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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