View Full Version : Dependent Drop-down Boxes


sclark
09-17-2008, 04:50 AM
Anyone know some simple code to make a secondary drop-down (not a pick list) dependent on the selection of the primary drop-down? I have the code that adds the 30 values (why I used a drop-down vs. a pick list) for the primary drop-down which works well. I know that I need code in the change event of the primary drop-down that references the primary values and establishes the secondary domain values, but not sure of the exact syntax.

KenHigg
09-17-2008, 04:53 AM
Do a search on the forum on 'Cascading Combo Boxes'.

sclark
09-17-2008, 05:00 AM
Thanks! Lots of good info for Access combo boxes, but I did not see any for a Word document.

KenHigg
09-17-2008, 05:19 AM
Oh - Darn... Didn't even notice it was a Word issue. Maybe somebody else can help, I've never done this type stuff in Word....

chergh
09-17-2008, 05:30 AM
Where is the data for these boxes coming from? I've done similar in excel and essentially you need to iterate through the list and where the primary value matches what is in the primary dropdown you need to use the additem method of the second combo box for the secondary domain value.

sclark
09-17-2008, 06:42 AM
The data is created programatically by using the ".AddItem" VB command in Word. I have created dependent comboboxes in both Access and Excel, and understand the logic. I just need nelp with the VB syntax in Word.

chergh
09-17-2008, 10:58 AM
Ah word combo boxes are completely different to what I thought. Have a look at http://msdn.microsoft.com/en-gb/library/aa221440(office.11).aspx which seems to explain it quite well.

I don't have access to word on this computer but post back if you need help with a specific bit of syntax.

sclark
09-17-2008, 11:06 AM
I did use something similar for the primary dropdown. Then for the secondary (dependent) dropdown, I fell back on a series of If Then and AddItem statements to populate the secondary. Probably pretty crummy programming. I am sure that there is a much better (and shorter) way to do it using arrays and cases, but I have it in good working order now

Thanks!.