Auto populate fields after drop down item selected

S

Skrewdriver1979

I am working on editing a word document that must stay a word document for
work purposes. Using a form view, i have added 5 names to a drop down menu.
The next step i am looking to do is after a name is selected out of the drop
down, is it possible for another designated feild to auto populate their
phone number?

There are only 5 names and 1 number for each person, however they are
located on seperate sections of the form.
 
G

Gregory K. Maxey

You need to run an On Exit macro from your name field that evaluates and
populates the phone number field based on the selection. Something like
this:

Sub OnExitDDNameList()
Select Case ActiveDocument.FormFields("NameDD").Result
Case "Bill Smith"
ActiveDocument.FormFields("PhoneNum").Result = "457-1234"
Case "Sandy Jones"
ActiveDocument.FormFields("PhoneNum").Result = "888-2345"
Case "Earl Smuckatelli"
ActiveDocument.FormFields("PhoneNum").Result = "123-9876"
End Select
End Sub
 
A

alborg

Hi Greg:

I would do a slight change, since I think he's talking about a UserForm
Combobox. You have to use the undocumented "Click" event, which is a takeoff
from the MS Access "OnClick" event-

Sub ComboBox1_Click()
Select Case ComboBox1.Value
Case "Bill Smith"
[PhoneField] = "457-1234"
Case "Sandy Jones"
[PhoneField] = "888-2345"
Case "Earl Smuckatelli"
[PhoneField] = "123-9876"
End Select
End Sub

Now, if the ComboBox is linked to a MS Access table, and there is a second
ComboBox column with phone numbers, you can do this:

Sub ComboBox1_Click()
[PhoneField] = ComboBox1.Column(1)
End Sub

Cheers,
Al
 

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