Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Drop-down box

0 views
Skip to first unread message

Ray Vaughan@discussions.microsoft.com Stevie Ray Vaughan

unread,
Jan 6, 2005, 8:25:02 AM1/6/05
to
Is there a way to set up a form with two drop-down boxes where when you enter
information in the first drop-down box it will give you the associated
choices to pick form in the second drop-down box.
Example: The first drop-down box would give you a choice of states and when
you make a selection then the 2nd drop-down box would give you a choice of
counties in that state to select from.

Thanks

Jay Freedman

unread,
Jan 6, 2005, 11:24:34 AM1/6/05
to

There is a way, but it's fairly complex and involves programming a macro,
which is selected as the "exit macro" for the first dropdown form field.
When the user selects an item in the first dropdown and then tabs or clicks
to the next field, the macro looks at the selection and populates the second
dropdown. The information for the second field can come from any of a number
of places -- data stored in the template, a separate Word document or text
file, a spreadsheet or database, even a web service.

If you want to save the user's choice so it's still there when they reopen
the document, that involves another macro.

Since you'd be programming anyway, a better alternative is a userform (a
custom dialog box) that's triggered by a button or field in the form. This
gives you more capabilities, such as repopulating the second list as the
user clicks an item in the first list without having to wait for them to
exit the list. Also, the dropdown form field you can use in the body of the
document is limited to 25 entries of 50 characters each, not enough for a
list of states or counties; userforms don't have that limitation. When the
user clicks the OK button, code in the userform puts the results into the
document.

See http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm for a short
tutorial to get started. If you run into problems, it would be better to
post in the microsoft.public.word.vba.userforms newsgroup (in the web
interface,
http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.word.vba.userforms).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org


0 new messages