Ask a Microsoft Word Question>I am making a form with conditonal drop down fields. I know I can make a drop down field conditional on another one. However, I need to make two or three different drop down fields conditional on a single other field. is this possible?Thanks,Jeff
I've played around with the VBE program shown at this website. http://vbaexpress.com/kb/getarticle.php?kb_id=5
Yes it is possible. The below link shows you how to make a DD bookmarked "DDSecondary" dependent on a selection in another dropdown bookmarkd "DDPrimary"
All you would need to do is create the additional dropdown objects e.g.:
Dim oDDim oDD As DropDownSet oDD2 = ActiveDocument.FormFields(AnnotherDD).DropDown
and then add the necessary lines of code in the Case statements.
Thanks for the quick response. I think I understand, but I am not a programmer. I've tried a couple times to modify my form per your instructions. So far it sort of works (I can get options to show up on the second conditional field, but they are not the correct options) but I still have problems. I suspect it is just coding errors on my part. Let me see if i can figure out what I may still be doing wrong. If I can get it to work correctly, I'll accept your answer by tomorrow. If not, I may need some additional guidance.
I still have a minor problem. I can get everything to work if my two conditional fields have the same number of options. For instance, given the first field is dropdown1, I can get the fields identified as dropdown2 and dropdown3 to both work if they each have 14 entries. If dropdown2 has 14 entries and dropdown3 has 7 entries, I can't seem to program them properly.
Here is an excerpt of my programming for this step:
ActiveDocument.FormFields("Dropdown3").DropDown.Value = 1
In this case, DefenceDD2 is a list of 14 entries. DefenceDD3 is a list of 7 entries. I get error messages. I can put seven blank lines in DefenceDD3, but that just doesn't seem to be the proper way to do it.
If you can mark up this excerpt to show me how to program it properly, I would appreciate it. If that is beyond the scope of your answer, I understand. You have given me enough that I can make it work, even if my programming sucks.
Well you didn't explain what DefenceDD2 or DefenceDD3 are but I assume they are arrays containing the list values. You are getting the error because you are trying obtain data that is out of scope.
Try this:Sub DD1OnExit()Dim var As LongDim aDefDD2() As StringDim aDefDD3() As StringaDefDD2 = Split("A1,A2,A3,A4,A5,A6,A7,A8,A(,A10,A11,A12,A13,A14", ",")aDefDD3 = Split("Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,Golf", ",")Select Case ActiveDocument.FormFields("DropDown1").DropDown.ValueCase 1ActiveDocument.FormFields("Dropdown2").DropDown.ListEntries.ClearActiveDocument.FormFields("Dropdown3").DropDown.ListEntries.ClearFor var = 0 To 13ActiveDocument.FormFields("Dropdown2").DropDown.ListEntries.Add Name:=aDefDD2(var)On Error Resume NextActiveDocument.FormFields("Dropdown3").DropDown.ListEntries.Add Name:=aDefDD3(var)On Error GoTo 0Next var'Or do it like this:ActiveDocument.FormFields("Dropdown2").DropDown.ListEntries.ClearActiveDocument.FormFields("Dropdown3").DropDown.ListEntries.ClearFor var = 0 To UBound(aDefDD2) ActiveDocument.FormFields("Dropdown2").DropDown.ListEntries.Add Name:=aDefDD2(var)Next varFor var = 0 To UBound(aDefDD3) ActiveDocument.FormFields("Dropdown3").DropDown.ListEntries.Add Name:=aDefDD3(var)Next varActiveDocument.FormFields("Dropdown2").DropDown.Value = 1ActiveDocument.FormFields("Dropdown3").DropDown.Value = 1Case 2End SelectEnd Sub
Microsoft Word Most Valuable Professional (6 years)