Drop-down box

G

Guest

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
 
J

Jay Freedman

Stevie said:
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

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/c...t.aspx?dg=microsoft.public.word.vba.userforms).
 

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