auto-fill the next 3 fields when selecting text from a dropdown

G

Guest

I currently have 4 dropdown fields on a form: Name - Position - Ext. Email.
I want the Position - Ext. & Email fields to auto-fill with the correct info,
when a name is selected. Note: Each name has unique data for each field. I
am ignorant when it comes to macros, so I need to have my hand held through
this one. Thanks.
 
S

Suzanne S. Barnhill

You may not need a macro; this can be done with IF fields, though it can get
pretty messy if there are a lot of names. How many names are there? Provide
some sample names and positions, and I'll provide some sample IF fields.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Graham Mayor

Essentially you would run a macro on exit from the dropdown field which
would populate the other fields eg

Sub OnExitDD1()
'fills text field based on content of _
dropdown field

Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
Select Case oFld("Dropdown1").Result
Case Is = "Bob"
oFld("Text1").Result = "867-5309"
oFld("Text2").Result= (e-mail address removed)
Case Is = "Joe"
oFld("Text1").Result = "911-1111"
oFld("Text2").Result = (e-mail address removed)
Case Else
'Do nothing
End Select
End Sub

You need a case statement and a set of results for each entry in the
dropdown (which here is bookmarked dropdown1 and fills fields text1 and
text2)

http://www.gmayor.com/installing_macro.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

I currently have 3 names - 3 postions - 3 Exts & 3 emails (each email is
identical after @...... sample:

[NAME] [POSITION] [EXT] (e-mail address removed)
 
S

Suzanne S. Barnhill

Use a dropdown form field for the name, and make sure that the bookmark of
this field (in the Form Field Options) is Name. Then, instead of inserting a
form field for Position, Ext, or Email, use fields such as the following:

For Position:

{ IF { REF Name } = "Willie Smith" "DIR" }{ IF { REF Name} = "John Jones"
"AD Ops" }{ IF { REF Name } = "Gail Storms" "AD Sales" }

For Ext:

{ IF { REF Name } = "Willie Smith" "111" }{ IF { REF Name} = "John Jones"
"112" }{ IF { REF Name } = "Gail Storms" "120" }

For Email:

{ IF { REF Name } = "Willie Smith" "wsmith" }{ IF { REF Name} = "John Jones"
"jjones" }{ IF { REF Name } = "Gail Storms" "gstorms" }@abc.com

Each pair of field delimiters (the things that look like braces but can't be
entered from the keyboard) must be inserted using Ctrl+F9. Note that
"Calculate on exit" must be checked in the Form Field Options for your Name
field, and that users must Tab out of the field (not just click the mouse
elsewhere) for the IF fields to be updated.

In this situation, you may find Graham's macro more practical.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Freddie Fredricks said:
I currently have 3 names - 3 postions - 3 Exts & 3 emails (each email is
identical after @...... sample:

[NAME] [POSITION] [EXT] (e-mail address removed)
 
G

Graham Mayor

If you prefer the macro solution, then the macro I posted earlier using your
further information would be

Sub OnExitDD1()
'fills text field based on content of _
dropdown field

Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
Select Case oFld("NAME").Result

Case Is = "Willie Smith"
oFld("POSITION").Result = "DIR"
oFld("EXT").Result = "111"
oFld("EMAIL").Result = "wsmith"

Case Is = "John Jones"
oFld("POSITION").Result = "Ad Ops"
oFld("EXT").Result = "112"
oFld("EMAIL").Result = "jjones"

Case Is = "Gail Storms"
oFld("POSITION").Result = "AdSales"
oFld("EXT").Result = "120"
oFld("EMAIL").Result = "gstorms"

Case Else
'Do nothing
End Select
End Sub

Set the bookmark name of the dropdown field to NAME
the bookmark name of the position field to POSITION
the bookmark name of the extension field to EXT
and the bookmark name of the email field to EMAIL

(right click the fields > properties)

See http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Freddie said:
I currently have 3 names - 3 postions - 3 Exts & 3 emails (each email
is identical after @...... sample:

[NAME] [POSITION] [EXT]
(e-mail address removed)
 

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