View Single Post
 
Old 09-29-2015, 09:11 AM
yeatropulo yeatropulo is offline Windows XP Office XP
Novice
 
Join Date: Aug 2015
Posts: 8
yeatropulo is on a distinguished road
Default VBA coding for multiple drop-down lists to populate a text box for each list

Can anybody help... I'm trying to create a word document well an order form actually with lines of products each of which can have several variants with a different value hence the drop-down list. I want to be able for the user on choosing the product's variant to see it's value in the adjacent text box/field. My aim is to have a final shopping list as it were and on each line a value with a total at the bottom. I have figured out the maths bit and am able to total the numbers at the end, what I can't manage is to create more than one drop-down list and auto text box. Hope that makes sense and someone is able to help.

This is the code I'm using to populate the text box with a value.



Option Explicit

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
If .Title = "Choice1" Then
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
Exit For
End If
Next
ActiveDocument.ContentControls(2).Range.Text = StrDetails
End If
End With
End Sub
Reply With Quote