Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching fields from a drop-down box to another list

Status
Not open for further replies.

pi

Technical User
Feb 13, 2001
11
0
0
AU
Is it possible to match the choice from a drop-down box to insert a corresponding field(matching field) in a text box when I choose from a dropdown box.
In excel this is possible but I do not know how to achiev this in word.

If someone can point me in the direction I would be extremely grateful

Dasi
 
If the drop-down list is a custom VB list box or combo box in your document, then clicking on it is an "event" which can be used to trigger some code which will update your text box.

You'd need to go into the Listbox1.Click event subroutine and add code like:

For Counter = 0 to Listbox1.ListCount
If Listbox1.Selected(Counter) then
Textbox1.Text = Listbox1.List(Counter)
Exit For
End If
Next

This basically loops through all the items listed in the Listbox, tests whether each one is Selected (the one you clicked will be selected), and, when it finds the selected item, passes its List value (i.e., what you see in the listbox) to your Textbox.Text property. It then terminates the loop (so as not to bother testing the rest of the items in the list).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top