Tab order in a Word form

C

caneau

I have just read "How to set the tab order of a Word Form" at MVPS' site
http://word.mvps.org/FAQs/TblsFldsFms/SetTabOrder.htm
and tried to apply the second method (single OnExit for all form fields) to
a simple form I built just for practice (8 form fields, all text boxes) in a
table having 4 columns, 2 for the labels and 2 for the corresponding fields.
There is no typo in the document bookmarks names and compiling went fine.
Running the procedure from VBE, line by line, gives a perfect result, going
from field to field down the first Fields column then down the second
column.
If I start from the document (protected), the selection jumps from field 1
to field 3, from field 3 to field 5 ... each time I hit the TAB key as if
Word added a hit by himself.
I could not get rid of this effect. So I switched to a 2-column layout,
equalized by a column jump, without any table. The procedure goes fine down
the first column then the second.
Has anybody an explanation ?
Thanks
 
P

Peter Hewett

Hi caneau

The default tab order of FormFields in a table is left to right, top to bottom
irrespective of which order you add the FormFields in (which determines their names). I
suspect that the FormFields are not named in the order that you expect or that the order
of the FormFields is not set correctly in your code.

For instance if you set up the FormFields thus:
Text1 Text2
Text3 Text4
Text5 Text6
Text7 Text8

and you want to traverse them in the following order "1,3,5,7,2,4,6,8" the code would need
to look like this:

Select Case StrCurFFld
Case "Text1"
StrFFldToGoTo = "Text3"
Case "Text3"
StrFFldToGoTo = "Text5"
Case "Text5"
StrFFldToGoTo = "Text7"
Case "Text7"
StrFFldToGoTo = "Text2"
Case "Text2"
StrFFldToGoTo = "Text4"
Case "Text4"
StrFFldToGoTo = "Text6"
Case "Text6"
StrFFldToGoTo = "Text8"
Case "Text8"
StrFFldToGoTo = "Text1"
End Select

However,there are a number of problems with this code in that it does not work, well only
partly:
1. It only works with Text FormFields
2. It does not work if you press Shift+Tab (to move to the previous FormField)
3. It does not work with the mouse
4. It does not account for disabled FormFields

If you are interested I have an AddIn that will allow you to set the tab order of any
number/type of FormField using a simple user interface. If you are interested email me
at:

nospaminnerword at xtra dot co dot nz

remove the "nospam" and replace dot with . and at with @. Also because I run two spam
filters (one at my ISP and one on my PC) you message will NOT get through unless you mark
the subject line: "microsoft.public.word.vba.general Set FormField Tab Ordering"

HTH + Cheers - Peter
 

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