PDA

View Full Version : populate one dropdown box from selecting another one



vampyricus
03-06-2015, 02:14 PM
I have a word doc with several dropdown boxes.

What I need to know is if there is a way to link dropdown boxes so that when dropdown box number 3 is changed it then populates a specific entry into dropdown boxes 5 and 6?

or of there is another way to do it using some sort of table and a text box or something in place of boxes 5 and 6?

example - jack jones is selcted in dropdown box 3 and then dropdown 5 adds jacks address and dropdown 6 adds jacks phone number


if there is an easier way to do this with another application then perhaps someone can point me in the right direction?

gmaxey
03-06-2015, 03:13 PM
It can certainly be done. The best way depends on the version of Word and the type of dropdown.

For a basic method using Word 2007 or above with content control dropdowns see: http://gregmaxey.mvps.org/word_tip_pages/linked_content_control_dropdown_list.html


http://gregmaxey.mvps.org/word_tip_pages/content_control_tools.html

Using formfields see: http://gregmaxey.mvps.org/word_tip_pages/content_control_tools.html

vampyricus
03-06-2015, 08:59 PM
cool thank you. I will take a look at that

vampyricus
03-07-2015, 11:32 AM
ok .. first problem i hav run across .. i dont have and cannot seem to get enabled the add-ins tab

gmaxey
03-07-2015, 02:50 PM
The Add-In tab is visible if there are one or more add-ins loaded.

vampyricus
03-07-2015, 08:02 PM
ok i'm still not seeing an addins tab on the ribbon
I have attached a screenshot of what i see in my options

12971

gmaxey
03-07-2015, 08:32 PM
I've edited my first post. It looks like I gave you the wrong link for CCs. The add-ins tab is not displayed until you load one or more template add-ins. If you load the CC Mapping Tools Add-in then it launch icon will appear on the Add-ins Tab.

vampyricus
03-09-2015, 06:40 PM
i followed the instructions. added the code to my document as the page instructs me to, changed whatever lines i could find that referred to the named dropdown boxes as far as i could see but after saiving the project and then testing it, it doesnt appear to be working. when i click the first dropdown box it isnt populating the appropriate dropdown in the linked box.



Option ExplicitDim i As Long
Private Type ListData
arrFood() As String
End Type


Private Sub Document_ContentControlOnEnter(ByVal CC As ContentControl)
'Delete next line if you are using Word2010 exclusively
Select Case CC.Tag
Case Is = "Choose club"
With ActiveDocument.SelectContentControlsByTitle("Signature owner").Item(1)
For i = .DropdownListEntries.Count To 2 Step -1
.DropdownListEntries(i).Delete
Next i
.DropdownListEntries(1).Select
End With
CC.DropdownListEntries(1).Select
End Select
lbl_Exit:
Exit Sub
End Sub


Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim tData As ListData
'Delete next line if you are using Word2010 exclusively
Select Case CC.Tag
Case Is = "Choose club"
tData = GetLEData(CC)
With ActiveDocument.SelectContentControlsByTitle("Signature owner").Item(1)
For i = .DropdownListEntries.Count To 2 Step -1
.DropdownListEntries(i).Delete
Next i
For i = 0 To UBound(tData.arrFood)
.DropdownListEntries.Add tData.arrFood(i)
Next i
.DropdownListEntries(1).Select
End With
End Select
lbl_Exit:
Exit Sub
End Sub


Private Function GetLEData(ByRef oCCPassed) As ListData
For i = 1 To oCCPassed.DropdownListEntries.Count
If oCCPassed.Range.Text = oCCPassed.DropdownListEntries(i).Text Then
GetLEData.arrFood() = Split(oCCPassed.DropdownListEntries(i).Value, "|")
Exit For
End If
Next i
lbl_Exit:
Exit Function
End Function

I am also not sure how to add additional dropdowns into the coding

gmaxey
03-09-2015, 06:53 PM
Send me website feedback. I'll reply and then you can send your document to me and I'll take a look.

vampyricus
03-09-2015, 07:27 PM
sent ty

gmaxey
03-10-2015, 04:38 PM
There have been several related posts on this topic in support groups that I haunt in the last few weeks. I've decided to ovehaul and consolidated my old content on the subject in one comprehensive web page article. If anyone has feedback, recommendations for improvement, gripes or sees fault, please let me know.

http://gregmaxey.mvps.org/word_tip_pages/link_content_to_dropdown_list.html

vampyricus
03-11-2015, 01:21 AM
thanks for the attempts at help but im afraid i just dont understand all the coding and i cant see how to adapt it to suit the sources etc that i have in the project i was trying to work up so i am just going to give up and go with my heaps messier method of individual documents for each of teh entries i needed.