How do I auto populate a field based off of my list selection

J

Julie

OK, here it goes :)

I dont know anything about VBA and I'm thinking I will need to learn to do
what I want to do in my .doc.

I have a table of 'contact info' in my document which I'm going to lock so
that it will be used as a template for others (where they can only update
certain fields and select information that I've provided).

I have two lists now in .doc but it's messy...l:
Name Email address

Currently if I pick the name, then I have to go to the Email address list
and pick the corresponding email address.

What I want to have happen is if I pick a Name on the left, the Email
address will autopopulate in the list by itself.

One step further, and even better:
To not even have an email address 'list', but have word just insert the
email address in the cell to the right of "Name"...I just don't know how to
create the list of values for it to populate based off of the selection in
the list.

Again, I don't know VBA here so please be clear :)))

Thank you for any help,
Julie
 
M

macropod

Hi Julie,

If you've got Excel, this would really be much easier to do there. Excel has built in functions for looking-up and returning data
from a table, without the need to resort to vba.

Cheers
 
D

Doug Robbins - Word MVP

If you create an autotext entry containing each email address with that
autotext entry having the corresponding name that would be in the list from
which you want the users to pick (actually assumed to be a DropDown type
FormField as you say that you are going to protect the document, you could
use the following code in a macro that is run on exit from the DropDown
FormField:

' Macro created 15-11-97 by Doug Robbins to add the address corresponding to
a drop down name

'

Set myDrop = ActiveDocument.FormFields("Dropdown1").DropDown

Company = myDrop.ListEntries(myDrop.Value).Name

Address = ActiveDocument.AttachedTemplate.AutoTextEntries(Company).Value

ActiveDocument.FormFields("Text1").Result = Address



End Sub

I would suggest however that you consider the use of a user form, but you
will have a bit of learning to do. In the first instance, you should
probably work your way through the following articles

Please Fill Out This Form
Part 1: Create professional looking forms in Word
http://www.computorcompanion.com/LPMArticle.asp?ID=22

Part 2: Adding Automation to your Word forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=46

Part 3: Learn more VBA (macros) to automate your forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=119

Part 4: Use custom dialog boxes in your Word forms
http://www.computorcompanion.com/LPMArticle.asp?ID=127

Part 5: Connect your AutoForm to a database to save input time and keep
better records!
http://www.computorcompanion.com/LPMArticle.asp?ID=136


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Julie

Thank you Doug.

This is a great start for me and you've provided wonderful direction :)

I was actually hoping for a response like this one so that I can educate
myself on VBA, user forms, etc. I had been searching high and low and didn't
know where to start.

Thanks again,
Julie
 
J

Julie

Hi macropod,

Unfortunately the template must stay .doc :(.

Thanks!
Julie

macropod said:
Hi Julie,

If you've got Excel, this would really be much easier to do there. Excel has built in functions for looking-up and returning data
from a table, without the need to resort to vba.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Julie said:
OK, here it goes :)

I dont know anything about VBA and I'm thinking I will need to learn to do
what I want to do in my .doc.

I have a table of 'contact info' in my document which I'm going to lock so
that it will be used as a template for others (where they can only update
certain fields and select information that I've provided).

I have two lists now in .doc but it's messy...l:
Name Email address

Currently if I pick the name, then I have to go to the Email address list
and pick the corresponding email address.

What I want to have happen is if I pick a Name on the left, the Email
address will autopopulate in the list by itself.

One step further, and even better:
To not even have an email address 'list', but have word just insert the
email address in the cell to the right of "Name"...I just don't know how to
create the list of values for it to populate based off of the selection in
the list.

Again, I don't know VBA here so please be clear :)))

Thank you for any help,
Julie
 

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