PDA

View Full Version : Change Tab Order for Word Form does not work: skips one field



JARivera
04-26-2007, 10:51 AM
I tried Q212378 from MS KB in order to change the tab order on a form. The same basic approach appears in several MVPs sites. However, when I try it, what ends up happening is that the Exit event gets fired twice (once on the original field and then once again, reporting the destination field for the first redirect), so what ends up happening is that the third is selected. Let me try to show what I need. This is the layout and tab order of the fields I need:

1 4
2 5
3 6

But, instead of the Exit event getting fired once for (1) and moving on to (2), it gets fired twice, once for (1), and then for (2), so the cursor moves to field (3). I guess it might have to do with timing, but I tried several tricks and still doesn't seem to work...

What kinda irks me is that I have seen several samples where this seems to work fine, but they are password-protected, so I can't read the view the source code...

Any ideas or suggestions?

Arturo

lucas
04-26-2007, 07:53 PM
Maybe this (http://word.mvps.org/FAQs/TblsFldsFms/SetTabOrder.htm) will help...

JARivera
04-27-2007, 08:34 AM
Actually, that was exactly the code I tried first, which is the one that goes on skipping fields (upon exit of 1, goes to 3 instead of 2, and so on)... so, thanks, but it doesn't seem to work.

lucas
04-27-2007, 08:50 AM
If you read it then you know they suggest a userform solution.....can that be implemented into your project?

JARivera
04-27-2007, 11:48 AM
Thanks for the suggestion. Normally, I would use a User Form to capture complex information, but for this particular application, it would be too obtrusive for the users. The idea for changing tabs is that it would make filling the form flow more smoothly: the left side is the "From" of a courier slip, and the right side is the "To".
In the end, I just managed to get this solved, but is a rather nasty tweak. I turned on a timer, and did not process "on exit" events until the timer ended. When the timer finished (1 sec), it would just go to the appropriate field, and then it works, although you do get a weird flick when the selected field moves around a bit until it returns to the right destination. I guess this will have to do for now...

Thanks a lot!

lucas
04-27-2007, 12:02 PM
Try

application.screenupdating = False

at the begining of your routine and be sure to return it to true at the end. That might help with the screen flickering.

JARivera
04-27-2007, 03:58 PM
Thanks... indeed, it looks much better now!

lucas
04-27-2007, 06:15 PM
Arturo, please mark your thread solved if it is using the thread tools at the top of the page..you can still post follow up questions if you need to.