Tab order on form issue

J

jkitzy

<sigh> This is frustrating me. I'm sure the answer is simple, but I can't
find it. Bear with me.

I have a form with non-ActiveX fields in Word 2003. FieldA is a drop-down
and based on the choice (with an OnExit macro), fields after FieldA become
either enabled or disabled.

Let's say I have text field FieldA_1A and dropdown FieldA_2A. Depending on
my choice in FieldA, one or the other of those two are enabled. Both are
disabled to start (you must choose something from FieldA to enable the
appropriate field.

My problem is that when I tab out, FieldB (which is after these) is where my
selection goes, even when I select the appropriate field at the end of the
exit macro.

Any suggestions? Code is below:
===============
Sub goRate()
'get section number
a = Selection.Information(wdActiveEndSectionNumber)
'Assign CR Section
a = a - 4
'Run Rate function for request
Rate (a)
'Select RateFix in curent CR
ActiveDocument.FormFields("CR" & a & "_RateFix").Select
End Sub
===============
The Rate function enables/disables various fields based on the choice made
in the source field. But when this is finished running, it jumps to the field
AFTER the recently enabled/disabled fields, skipping over the enabled fields
even though, darn it, I select it in the code...

Any thoughts? I know this must be simple. I'm not used to using VBA in Word
- it's unusually different than VBA in Excel.
 
J

Jay Freedman

I suspect you're running into a timing issue similar to the one discussed in
http://word.mvps.org/faqs/tblsfldsfms/ValidateFFields.htm. Try the solution
given there, of selecting the field in a separate procedure called by the
OnTime method.

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

jkitzy

I can see how that would work. Cool. Thanks. Unfortunately, that doesn't seem
to do the trick because that field it goes to (FieldB in my example) has an
On Entry macro that fires a UserForm. :(

Any other thoughts?
 
J

Jay Freedman

It's getting more complicated than I'd recommend, but...

If the exit macro from FieldA sets a global Boolean variable to True when it
enables FieldA_1A and FieldA_2A, then the entry macro of FieldB could look
at that variable and not fire the userform if it's True. The variable should
be reset to False if the FieldA exit macro disables the other two fields,
and you'd also need entry macros for FieldA_1A and FieldA_2A to reset the
variable to False (so if the user goes from the enabled FieldA_2A to FieldB
the userform fires).

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

jkitzy

Thanks, Jay. This worked! This is a way-too-complicated form already. I have
sections that have to expand/contract based on choices, that have to
hide/unhide so there aren't empty sections when the users print/view,
repeating sections the users can fold/unfold, sections that feed other
sections with information, and sections that are unprotected so the users can
free-form whatever they want.

My current field count is over 1025... Frankly, I'd really rather do a form
like this in Excel or Acrobat, but the users need to be able to format the
text and save. Plus, even though they are bankers, they seem to have little
expertise with Excel - even the basics of navigating around in it. Plus I
can't control the final look as well in Excel. This project is a challenge
for sure, but it'll be great when it's done. Thanks again for your 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