Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word forms..dropdown lists

Status
Not open for further replies.

Herriot

MIS
Dec 14, 2001
45
GB
Apologies if this has been asked and/or answered elsewhere.

Using MS Word forms...

Is it possible to display a second dropdown list containing data based on a user choice from a first dropdown.

For example:

Drop1 is a list of printer companies (HP, Epson ect)
Drop2 is a list of models for whatever make is chosen above.

So if the user chooses HP only models pertaining to that make is shown..the extension to this is the user would then choose the model and only consumables for that model are then displayed.

Hope this is understandable.

Thanks in advance
 
Herriot ..
Yes, it is possible.
Populte the first list as normal. Then I do a public module that uses a Select Case based on List1.selText to populate the second. This is only one method of several possiblities.
HTH
Michael
 
Thanks Michael

I presume I'll need to delve into VB?

I am not too much of an expert on VB but I give it a go.

Peter
 
The code below seemed to work fine. right click on the first combo box and choose properties. Find Run MAcro on Exit and then find the sub in the list and voila. Also make sure you insert the macro in the document rather than in your normal template.

Sub PopuCombo()
Dim strCboVal As String
Dim ffField As FormField
'assign first combobox value to variable
strCboVal = ActiveDocument.FormFields.Item("foods").Result
'assign formfield object (2nd combo) to variable
Set ffField = ActiveDocument.FormFields.Item("types")
'clear the 1st combo
ffField.DropDown.ListEntries.Clear
' add different values to combobox 2 dependant on combobox 1's value
Select Case strCboVal
Case "Cheese" 'if box one is cheese add cheese types
With ffField
.DropDown.ListEntries.Add "Gouda"
.DropDown.ListEntries.Add "Cheddar"
.DropDown.ListEntries.Add "Muenster"
End With
Case "milk" 'if box one is milk add milk types
With ffField
.DropDown.ListEntries.Add "Whole"
.DropDown.ListEntries.Add "Skim"
End With
Case "meats" 'if box one is meats add meat types
With ffField
.DropDown.ListEntries.Add "Beef"
.DropDown.ListEntries.Add "Pork"
.DropDown.ListEntries.Add "Wildebeest"
End With
Case Else
ffField.DropDown.ListEntries.Add "Make Entry in Box 1 First!"
End Select
End Sub
hope this helps,
sdraper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top