User Form Question

A

abs

I have a beautiful user form that pops up when the template is accessed to
request information and then fills in the letter...no problem with that. One
of the entries is to be a name and address for one of the 67 district
attorneys within the state. I have all the names and address for the 67
counties in an Excel spreadsheet (and could move those to a text file if
appropriate). I would like to be able to have the user simply select the
county name from a list and then the name and address would automatically
fill in. I'm sure there is a way to do so, I'm just at a loss as to how to
make it happen. We're using Word 2002 (going to 2003 in about a month). I
hope I've articulated this well enough that you can understand what I'm
trying to accomplish. As always, thanks for the help...don't know what I'd
do without you folks!
 
J

Jezebel

The steps could be along these lines --

1. Read the source data into an array:

Dim pADs(1 to 67, 1 to 4)
pADs(1,1) = Name1
pADs(1,2) = Address1
pADs(1,3) = County1
:

You could read the data directly from the Excel workbook (easy to change the
data, slower to run); or hard code the data into your Userform (hard to
change, quick to run).

2. Populate the Counties list box. Put the array index value into the
ItemData() property in each case.

3. When the user selects a county, look up the corresponding values from the
array an insert them into the other textboxes --

pIndex = listbox.ItemData(listbox.ListIndex)
txtName = pADs(pIndex ,1)
txtAddress = pADs(pIndex ,2)
:
 

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